﻿#include"pch.h"
#include<graphics.h>
#include<conio.h>
#include <tchar.h>
#pragma comment(lib,"Winmm.lib")
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//#include<Windows.h>
//#define KEY_DOWN(VK_NONAME)(GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)

constexpr auto width = 1200;
constexpr auto high = 675;
//定义农场结构体：
struct farm
{
	int farm_x[5], farm_y[5];//农场位置
	IMAGE Farm1;
	IMAGE Farm2;
	int num;
	int exit[5];
};
struct farm f;
//定义银厂结构体：
struct silver
{
	int silver_x[5], silver_y[5];//银厂位置
	IMAGE Silver1;
	IMAGE Silver2;
	int num;
	int exit[5];
};
struct silver s;
//定义马厩结构体：
struct stable
{
	int stable_x, stable_y;     //定义马厩位置
	IMAGE Stable1;
	IMAGE Stable2;
	int exit;
};
struct stable st;
//定义激光炮结构体：
struct LightWeapon
{
	int LightWeapon_x[8], LightWeapon_y[8];
	IMAGE LightWeapon1, LightWeapon2;
	int exit[8];
	int num;
};
struct LightWeapon L;
//定义兵营：
struct SoldierLand
{
	int Soldierland_x, soldierland_y;
	IMAGE Soldierland1, Soldierland2;
	int exit;
};
struct SoldierLand sol;
//定义老师召唤阵：
int ExistCallTeacher;
IMAGE CALL_1, CALL_2;
//定义光棱塔：
int existLT;
IMAGE LightTower1, LightTower2;

//背景图片
IMAGE img_bk;

//第一信息版面
char CharMoney[] = "Money";
int Moneyshu;                 //金钱
char Charfarm[] = "Farm";
int Farmshu;                  //农场
char Charsilver[] = "silver";
int silvershu;                //银厂
char CharpopulationF[] = "populationF";
int populationFshu;           //人口
char Charpopulation[] = "population";
int populationshu;            //人口

//骑士
constexpr auto KnightNum = 20;//数量
IMAGE knight1, knight2;//图像
int knightI;//动画
int ExistKnight[KnightNum];
int pKx[KnightNum], pKy[KnightNum];
int knightad;//攻击距离
int HPknight[KnightNum];
int ismoveK[KnightNum];
int keepK[KnightNum];

//普通学生
constexpr auto CommonStudentNum = 20;//数量
IMAGE CommonStudent1, CommonStudent2;//图像
int CommonStudentI;//动画
int ExistCommonStudent[CommonStudentNum];
int pCSx[CommonStudentNum], pCSy[CommonStudentNum];
int CommonStudentad;//攻击距离
int HPCommonStudent[CommonStudentNum];
int ismoveCS[CommonStudentNum];
int keepCS[CommonStudentNum];

//计科老师
constexpr auto TTeacherNum = 20;//数量
constexpr auto BookNum = 10000;//数量
IMAGE TTeacher1, TTeacher2;//图像
int TTeacherI;//动画
int ExistTTeacher[TTeacherNum];
int pTTx[TTeacherNum], pTTy[TTeacherNum];
int TTeacherad;//攻击距离
int HPTTeacher[TTeacherNum];
int ismoveTT[TTeacherNum];
int keepTT[TTeacherNum];
int book_x[BookNum], book_y[BookNum];
int ExistBook[BookNum];
IMAGE BOOK1, BOOK2;
IMAGE MagicFiled1, MagicFiled2;
int MF_x[BookNum], MF_y[BookNum];
int ExistMagicFiled[BookNum];
int xiu[BookNum];
IMAGE BOOM_1, BOOM_2;
int existboom[BookNum];
int Boom_I;
int boom_x, boom_y;

//一级僵尸
constexpr auto Zombie1Num = 20;
IMAGE zombie1_1, zombie1_2;
int zombie_1I;
int ExistZombie1[Zombie1Num];
int pZ_1x[Zombie1Num], pZ_1y[Zombie1Num];
int HPzombie1[Zombie1Num];
int zombie1ad;
int ismoveZ1[Zombie1Num];
int keepZ1[Zombie1Num];
int Z1_AON;

//二级僵尸meat
constexpr auto ZombieMeatNum = 20;
IMAGE ZombieMeat_1, ZombieMeat_2;
int ZombieMeat_I;
int ExistZombieMeat[ZombieMeatNum];
int pZ_Mx[ZombieMeatNum], pZ_My[ZombieMeatNum];
int HPZombieMeat[ZombieMeatNum];
int ZombieMeatad;
int ismoveZM[ZombieMeatNum];
int keepZM[ZombieMeatNum];
int ZM_AON;

//三级僵尸瘦子
constexpr auto ZombieThinNum = 20;
constexpr auto BulletNum = 10000;
IMAGE ZombieThin_1, ZombieThin_2;
int ZombieThin_I;
int ExistZombieThin[ZombieThinNum];
int pZ_Tx[ZombieThinNum], pZ_Ty[ZombieThinNum];
int HPZombieThin[ZombieThinNum];
int ZombieThinad;
int ismoveZT[ZombieThinNum];
int keepZT[ZombieThinNum];
int ThinBullet_x[BulletNum], ThinBullet_y[BulletNum];
int ExistBullet[BulletNum];
IMAGE Bullet1, Bullet2;
int ZT_AON;


//四级僵尸蝙蝠：
constexpr auto ZombieBatNum = 20;
IMAGE ZombieBat_1, ZombieBat_2;
int ZombieBat_I;
int ExistZombieBat[ZombieBatNum];
int pZ_Bx[ZombieBatNum], pZ_By[ZombieBatNum];
int HPZombieBat[ZombieBatNum];
int ZombieBatad;
int ismoveZB[ZombieBatNum];
int keepZB[ZombieBatNum];
int ZB_AON;
int Rand_Bat_y[ZombieBatNum];
int Jamp[ZombieBatNum];

//计科猛男：
constexpr auto ToughStudentNum = 20;//数量
IMAGE ToughStudent1, ToughStudent2;//图像
IMAGE Tough_A1, Tough_A2;
int ToughStudentI_1;//动画
int ToughStudentI_2;
int ExistToughStudent[ToughStudentNum];
int pTSx[ToughStudentNum], pTSy[ToughStudentNum];
int ToughStudentad;//攻击距离
int HPToughStudent[ToughStudentNum];
int ismoveTS[ToughStudentNum];
int keepTS[ToughStudentNum];

//建筑：
int farm_i;        //定义农场初始个数
int silver_i;      //定义银厂初始个数
int lightweapon_i; //定义激光炮初始个数

//基础设施
IMAGE img_zombieHQ1;  //僵尸总部图像
IMAGE img_zombieHQ2;
IMAGE HuBasement1;   //人类基地图像
IMAGE HuBasement2;   //人类基地图像
int basement_x, basement_y;               //定义人类基地的位置
int zombieHQ_x, zombieHQ_y;               //定义僵尸总部的位置
int basementHP;                              //定义人类基地血量
int zombieHQHP;                              //定义僵尸基地血量
//定义双方基地血量格数
int zombie_blood_appear[20];
int human_blood_appear[20];
int start_zombieHQHP;                   //定义双方基地初始血量
int start_basementHP;
int zombieHQ_length;                    //定义双方基地血条长度
int basement_length;
int zombieHQ_blood_x;                    //定义双方基地血条起始位置             
int basement_blood_x;

//鼠标：
int mouseplace_x, mouseplace_y;

//定义按钮图像和位置
IMAGE student_button;
IMAGE knight_button;
IMAGE teacher_button;
IMAGE magic_button;
IMAGE mystic_button;
IMAGE lightweapon_button;
IMAGE lighttower_button;
IMAGE farm_button;
IMAGE silver_button;
IMAGE stable_button;
IMAGE soldierland_button;
IMAGE mengnan_button;
IMAGE radar_button;
IMAGE danghui_button;

//定义说明图像IMAGE 
IMAGE student_int;
IMAGE knight_int;
IMAGE teacher_int;
IMAGE mengnan_int;
IMAGE mystic_int;
IMAGE lightweapon_int;
IMAGE lighttower_int;
IMAGE farm_int;
IMAGE silver_int;
IMAGE stable_int;
IMAGE soldierland_int;
IMAGE magic_int;
IMAGE danghui_int;
IMAGE radar_int;

//定义开始与结束界面
IMAGE startpicture;
IMAGE end_Win;
IMAGE end_Lose;
IMAGE end_Lanping;
IMAGE end_Tongjing;
//定义游戏状态
int gameStatus = 0;     //0为开始界面，1为正常游戏，2为失败结束游戏，3为童晶结束游戏,4为胜利结束游戏



//定义按钮位置
//第一排：人类
int student_b_x = 700, student_b_y = 10;
int knight_b_x = 770, knight_b_y = 10;
int teacher_b_x = 840, teacher_b_y = 10;
int danghui_x = 920, danghui_y = 10;

//第一排：防御建筑
int lightweapon_b_x = 1000, lightweapon_b_y = 10;
int lighttower_b_x = 1070, lighttower_b_y = 10;
int mystic_b_x = 1140, mystic_b_y = 10;
//第二排：资源建筑
int farm_b_x = 700, farm_b_y = 80;
int silver_b_x = 770, silver_b_y = 80;
int mengnan_b_x = 840, mengnan_b_y = 80;
//第二排：科技建筑
int radar_x = 920, radar_y = 80;
int stable_b_x = 1000, stable_b_y = 80;
int soldierland_b_x = 1070, soldierland_b_y = 80;
int magic_b_x = 1140, magic_b_y = 80;

//定义说明位置
int introduction_x = 300, introduction_y = 20;

//雷达射炮：
constexpr auto Shellnum = 10000;//数量
int ExistRADAR = 0;//射炮存在与否
IMAGE Radar_Cannon_1, Radar_Cannon_2;
int ExistShell[Shellnum];//炮弹存在与否
int shell_x[Shellnum], shell_y[Shellnum];//炮弹坐标
int Vshell_x[Shellnum], Vshell_y[Shellnum];//炮弹速度
double VV;//速度控制
IMAGE shell_A_1, shell_A_2;
IMAGE shell_B_1, shell_B_2;
IMAGE shell_C_1, shell_C_2;
IMAGE shell_D_1, shell_D_2;
int Hot_Or_Not;
int Gun_x, Gun_y;

//BOSS僵尸瘟疫：
constexpr auto ZombieBossNum = 20;
IMAGE ZombieBossWalk_1, ZombieBossWalk_2;
IMAGE ZombieBossAttack_1, ZombieBossAttack_2;
int ZombieBossWalk_I;
int ZombieBossAttack_I;
int ExistZombieBoss[ZombieBossNum];
int pZ_Box[ZombieBossNum], pZ_Boy[ZombieBossNum];
int HPZombieBoss[ZombieBossNum];
int ZombieBossad;
int ismoveZBo[ZombieBossNum];
int keepZBo[ZombieBossNum];
int ZBo_AON;

void Button()
{
	//输出按钮
	putimage(student_b_x, student_b_y, &student_button);
	putimage(knight_b_x, knight_b_y, &knight_button);
	putimage(teacher_b_x, teacher_b_y, &teacher_button);
	putimage(mengnan_b_x, mengnan_b_y, &mengnan_button);
	putimage(lightweapon_b_x, lightweapon_b_y, &lightweapon_button);
	putimage(lighttower_b_x, lighttower_b_y, &lighttower_button);
	putimage(farm_b_x, farm_b_y, &farm_button);
	putimage(silver_b_x, silver_b_y, &silver_button);
	putimage(stable_b_x, stable_b_y, &stable_button);
	putimage(soldierland_b_x, soldierland_b_y, &soldierland_button);
	putimage(magic_b_x, magic_b_y, &magic_button);
	putimage(mystic_b_x, mystic_b_y, &mystic_button);
	putimage(radar_x, radar_y, &radar_button);
	putimage(danghui_x, danghui_y, &danghui_button);

}
void Introduction()
{
	if (Hot_Or_Not == 0)
	{
		if (mouseplace_x >= 700 && mouseplace_x <= 760 && mouseplace_y >= 10 && mouseplace_y <= 70)//第一排
			putimage(introduction_x, introduction_y, &student_int);
		if (mouseplace_x >= 770 && mouseplace_x <= 830 && mouseplace_y >= 10 && mouseplace_y <= 70)
			putimage(introduction_x, introduction_y, &knight_int);
		if (mouseplace_x >= 840 && mouseplace_x <= 900 && mouseplace_y >= 10 && mouseplace_y <= 70)
			putimage(introduction_x, introduction_y, &teacher_int);
		if (mouseplace_x >= 920 && mouseplace_x <= 980 && mouseplace_y >= 10 && mouseplace_y <= 70)
			putimage(introduction_x, introduction_y, &danghui_int);
		if (mouseplace_x >= 1000 && mouseplace_x <= 1060 && mouseplace_y >= 10 && mouseplace_y <= 70)
			putimage(introduction_x, introduction_y, &lightweapon_int);
		if (mouseplace_x >= 1070 && mouseplace_x <= 1130 && mouseplace_y >= 10 && mouseplace_y <= 70)
			putimage(introduction_x, introduction_y, &lighttower_int);
		if (mouseplace_x >= 1140 && mouseplace_x <= 1200 && mouseplace_y >= 10 && mouseplace_y <= 70)
			putimage(introduction_x, introduction_y, &mystic_int);

		if (mouseplace_x >= 700 && mouseplace_x <= 760 && mouseplace_y >= 80 && mouseplace_y <= 140)//第二排
			putimage(introduction_x, introduction_y, &farm_int);
		if (mouseplace_x >= 770 && mouseplace_x <= 830 && mouseplace_y >= 80 && mouseplace_y <= 140)
			putimage(introduction_x, introduction_y, &silver_int);
		if (mouseplace_x >= 840 && mouseplace_x <= 900 && mouseplace_y >= 80 && mouseplace_y <= 140)
			putimage(introduction_x, introduction_y, &mengnan_int);
		if (mouseplace_x >= 920 && mouseplace_x <= 980 && mouseplace_y >= 80 && mouseplace_y <= 140)
			putimage(introduction_x, introduction_y, &radar_int);
		if (mouseplace_x >= 1000 && mouseplace_x <= 1060 && mouseplace_y >= 80 && mouseplace_y <= 140)
			putimage(introduction_x, introduction_y, &stable_int);
		if (mouseplace_x >= 1070 && mouseplace_x <= 1130 && mouseplace_y >= 80 && mouseplace_y <= 140)
			putimage(introduction_x, introduction_y, &soldierland_int);
		if (mouseplace_x >= 1140 && mouseplace_x <= 1200 && mouseplace_y >= 80 && mouseplace_y <= 140)
			putimage(introduction_x, introduction_y, &magic_int);
	}

}

//开始结束界面
void start()
{
	loadimage(&startpicture, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\开始页面.jpg"));
	putimage(0, 0, &startpicture);
	setbkmode(TRANSPARENT);
	FlushBatchDraw();
	Sleep(2);

	char input;
	if (_kbhit())
	{
		input = _getch();
		if (input == ' ')
			gameStatus = 1;
	}
}
void end_win()
{
	loadimage(&end_Win, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\胜利结束页面.jpg"));
	putimage(0, 0, &end_Win);
	setbkmode(TRANSPARENT);
	FlushBatchDraw();
	Sleep(999999);
}
void end_lose()
{
	loadimage(&end_Lose, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\失败结束页面.jpg"));
	putimage(0, 0, &end_Lose);
	setbkmode(TRANSPARENT);
	FlushBatchDraw();
	Sleep(999999);
}
void end_tongjing()
{
	loadimage(&end_Lanping, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\蓝屏结束页面.jpg"));
	loadimage(&end_Tongjing, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\童晶结束页面.jpg"));
	putimage(0, 0, &end_Lanping);
	setbkmode(TRANSPARENT);
	FlushBatchDraw();
	Sleep(2000);
	putimage(0, 0, &end_Tongjing);
	setbkmode(TRANSPARENT);
	FlushBatchDraw();
	Sleep(999999);
}

void gameover()
{
	EndBatchDraw();
	_getch();
	closegraph();

}
void FirstInformationBoard()
{
	outtextxy(0, 0, "Money:");
	sprintf_s(CharMoney, "%d", Moneyshu);
	outtextxy(50, 0, CharMoney);

	outtextxy(115, 0, "Farm:  /5");
	sprintf_s(Charfarm, "%d", Farmshu);
	outtextxy(151, 0, Charfarm);

	outtextxy(210, 0, "Silver:  /5");
	sprintf_s(Charsilver, "%d", silvershu);
	outtextxy(251, 0, Charsilver);

	outtextxy(90, 20, "Population:    /   ");
	sprintf_s(CharpopulationF, "%d", populationFshu);
	outtextxy(185, 20, CharpopulationF);
	sprintf_s(Charpopulation, "%d", populationshu);
	outtextxy(163, 20, Charpopulation);
}
void TowBasement()
{
	//绘制人类基地
	putimage(basement_x, basement_y, &HuBasement2, NOTSRCERASE);
	putimage(basement_x, basement_y, &HuBasement1, SRCINVERT);
	//绘制僵尸总部
	putimage(zombieHQ_x, zombieHQ_y, &img_zombieHQ2, NOTSRCERASE);
	putimage(zombieHQ_x, zombieHQ_y, &img_zombieHQ1, SRCINVERT);
}
void HP()
{
	//计算僵尸基地血条
	int i;
	for (i = 0; i < 20; i++)
	{
		if (zombieHQHP >= i * (start_zombieHQHP / 20))
			zombie_blood_appear[i] = 1;
		else
			zombie_blood_appear[i] = 0;
	}
	for (i = 0; i < 20; i++)
	{
		if (zombie_blood_appear[i] == 1)
		{
			setcolor(WHITE);
			setfillcolor(RED);
			solidrectangle(zombieHQ_blood_x - i * (zombieHQ_length / 20), 660, zombieHQ_blood_x - (i - 1) * (zombieHQ_length / 20), 670);
			setcolor(WHITE);
			setfillcolor(BLACK);
			solidrectangle(zombieHQ_blood_x - i * (zombieHQ_length / 20) + zombieHQ_length / 22, 660, zombieHQ_blood_x - (i - 1) * (zombieHQ_length / 20), 670);

		}
	}
	//计算人类基地血条
	for (i = 0; i < 20; i++)
	{
		if (basementHP >= i * (start_basementHP / 20))
			human_blood_appear[i] = 1;
		else
			human_blood_appear[i] = 0;
	}
	for (i = 0; i < 20; i++)
	{
		if (human_blood_appear[i] == 1)
		{
			setcolor(WHITE);
			setfillcolor(RED);
			solidrectangle(basement_blood_x + i * (basement_length / 20), 660, basement_length + (i + 1) * (basement_length / 20), 670);
			setcolor(WHITE);
			setfillcolor(BLACK);
			solidrectangle(basement_blood_x + i * (basement_length / 20) + basement_length / 22, 660, basement_length + (i + 1) * (basement_length / 20), 670);
		}
	}

}
//金钱自增系统
void MoneyAdd()
{
	static int i = 0;
	i++;
	if (i == 3)
	{
		if (silvershu == 0)
		{
			Moneyshu += 1;
		}
		if (silvershu == 1)
		{
			Moneyshu += 3;
		}
		if (silvershu == 2)
		{
			Moneyshu += 5;
		}
		if (silvershu >= 3)
		{
			Moneyshu += 5 + (silvershu - 2);
		}
		//Moneyshu+=1+silvershu*2;
		i = 0;
	}
}
//建筑绘制函数
void farm()   //绘制农场
{
	for (f.num = 0; f.num < 5; f.num++)
	{
		if (f.exit[f.num] == 1)
		{
			putimage(f.farm_x[f.num], f.farm_y[f.num], &f.Farm2, NOTSRCERASE);
			putimage(f.farm_x[f.num], f.farm_y[f.num], &f.Farm1, SRCINVERT);
		}
	}
}
void silver()   //绘制银厂
{
	for (s.num = 0; s.num < 5; s.num++)
	{
		if (s.exit[s.num] == 1)
		{
			putimage(s.silver_x[s.num], s.silver_y[s.num], &s.Silver2, NOTSRCERASE);
			putimage(s.silver_x[s.num], s.silver_y[s.num], &s.Silver1, SRCINVERT);
		}
	}
}
void stable()    //绘制马厩
{
	if (st.exit == 1)
	{
		putimage(st.stable_x, st.stable_y, &st.Stable2, NOTSRCERASE);
		putimage(st.stable_x, st.stable_y, &st.Stable1, SRCINVERT);
	}
}
void lightweapon()
{
	for (L.num = 0; L.num < 8; L.num++)
	{
		if (L.exit[L.num] == 1)
		{
			putimage(L.LightWeapon_x[L.num], L.LightWeapon_y[L.num], &L.LightWeapon2, NOTSRCERASE);
			putimage(L.LightWeapon_x[L.num], L.LightWeapon_y[L.num], &L.LightWeapon1, SRCINVERT);
		}
	}
}
void soldierland()
{
	if (sol.exit == 1)
	{
		putimage(sol.Soldierland_x, sol.soldierland_y, &sol.Soldierland1, NOTSRCERASE);
		putimage(sol.Soldierland_x, sol.soldierland_y, &sol.Soldierland2, SRCINVERT);
	}
}
void LightTower()
{
	if (existLT == 1)
	{
		putimage(115, 283, &LightTower1, NOTSRCERASE);
		putimage(115, 283, &LightTower2, SRCINVERT);
	}
}
void teachercall()
{
	if (ExistCallTeacher == 1)
	{
		putimage(500, 141, &CALL_2, NOTSRCERASE);
		putimage(500, 141, &CALL_1, SRCINVERT);
	}
}
void radarlight()
{
	int i;
	i = rand() % 4;
	if (i == 0)
		setfillcolor(RED);
	else if (i == 1)
		setfillcolor(BLUE);
	else if (i == 2)
		setfillcolor(YELLOW);
	else if (i == 3)
		setfillcolor(GREEN);
	fillcircle(88, 100, 4);
}
void radar_cannon()
{
	if (ExistRADAR == 1)
	{
		putimage(15, 83, &Radar_Cannon_2, NOTSRCERASE);
		putimage(15, 83, &Radar_Cannon_1, SRCINVERT);
		radarlight();
	}

}

//相遇函数
void KnightMeet()
{
	int i, k;
	//骑士攻击
	for (i = 0; i < KnightNum; i++)
	{
		if (ExistKnight[i] == 1)
		{
			/*if (HPknight[i] <= 15)
			{

			}*/
			//判断骑士是否死亡：
			if (HPknight[i] <= 1)
			{
				ExistKnight[i] = 0;
				pKx[i] = 10;
				pKy[i] = 520;
				populationshu -= 1;
				mciSendString(_T("close kdie"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\骑士死亡.wav alias kdie"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play kdie"), NULL, 0, NULL);//仅播放一次
			}
			ismoveK[i] = 1;
			keepK[i] = 1;
			//当骑士遇到每一只zombie1：
			if (keepK[i] == 1)
			{
				for (k = 0; k < Zombie1Num; k++)
				{
					if (abs(pZ_1x[k] - pKx[i]) < knightad&&ExistZombie1[k] == 1)
					{
						HPzombie1[k] -= 30;
						ismoveK[i] = 0;
						keepK[i] = 0;
						if (HPzombie1[k] <= 1)
						{
							mciSendString(_T("close KAN"), NULL, 0, NULL);
							mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\骑士砍击.mp3 alias KAN"), NULL, 0, NULL);//打开KAN声音乐
							mciSendString(_T("play KAN"), NULL, 0, NULL);//仅播放一次
						}
						break;
					}
				}
			}
			//当骑士遇到每一只zombiemeat：
			if (keepK[i] == 1)
			{
				for (k = 0; k < ZombieMeatNum; k++)
				{
					if (abs(pZ_Mx[k] - pKx[i]) < knightad&&ExistZombieMeat[k] == 1)
					{
						HPZombieMeat[k] -= 30;
						ismoveK[i] = 0;
						keepK[i] = 0;
						if (HPZombieMeat[k] <= 1)
						{
							mciSendString(_T("close KAN"), NULL, 0, NULL);
							mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\骑士砍击.mp3 alias KAN"), NULL, 0, NULL);//打开KAN声音乐
							mciSendString(_T("play KAN"), NULL, 0, NULL);//仅播放一次
						}
						break;
					}
				}
			}
			//当骑士遇到每一只瘦子僵尸
			if (keepK[i] == 1)
			{
				for (k = 0; k < ZombieThinNum; k++)
				{
					if (abs(pZ_Tx[k] - pKx[i]) < knightad&&ExistZombieThin[k] == 1)
					{
						HPZombieThin[k] -= 30;
						ismoveK[i] = 0;
						keepK[i] = 0;
						if (HPZombieThin[k] <= 1)
						{
							mciSendString(_T("close KAN"), NULL, 0, NULL);
							mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\骑士砍击.mp3 alias KAN"), NULL, 0, NULL);//打开KAN声音乐
							mciSendString(_T("play KAN"), NULL, 0, NULL);//仅播放一次
						}
						break;
					}
				}
			}
			//当骑士遇到每一只boss僵尸
			if (keepK[i] == 1)
			{
				for (k = 0; k < ZombieBossNum; k++)
				{
					if (abs(pZ_Box[k] - pKx[i]) < knightad&&ExistZombieBoss[k] == 1)
					{
						HPZombieBoss[k] -= 30;
						ismoveK[i] = 0;
						keepK[i] = 0;
						if (HPZombieBoss[k] <= 1)
						{
							mciSendString(_T("close KAN"), NULL, 0, NULL);
							mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\骑士砍击.mp3 alias KAN"), NULL, 0, NULL);//打开KAN声音乐
							mciSendString(_T("play KAN"), NULL, 0, NULL);//仅播放一次
						}
						break;
					}
				}
			}
			//当骑士遇到僵尸基地
			if (keepK[i] == 1)
			{
				if (zombieHQ_x - pKx[i] < knightad)
				{
					zombieHQHP -= 1;
					ismoveK[i] = 0;
				}
			}
			//判断骑士是否移动
			if (ismoveK[i] == 1)
				pKx[i] += 5;
			putimage(pKx[i], pKy[i], 74, 110, &knight2, knightI * 74, 0, NOTSRCERASE);
			putimage(pKx[i], pKy[i], 74, 110, &knight1, knightI * 74, 0, SRCINVERT);
			//循环动作
			knightI += 1;
			if (knightI == 5)
				knightI = 0;
		}
	}
}
void CommonStudentMeet()
{
	int i, k;
	//普通学生攻击
	for (i = 0; i < CommonStudentNum; i++)
	{
		if (ExistCommonStudent[i] == 1)
		{
			//判断普通学生是否死亡：
			if (HPCommonStudent[i] <= 1)
			{
				ExistCommonStudent[i] = 0;
				pCSx[i] = 10;
				pCSy[i] = 520;
				populationshu -= 1;
			}
			ismoveCS[i] = 1;
			keepCS[i] = 1;
			//当普通学生遇到每一只zombie1：
			if (keepCS[i] == 1)
			{
				for (k = 0; k < Zombie1Num; k++)
				{
					if (abs(pZ_1x[k] - pCSx[i]) < CommonStudentad&&ExistZombie1[k] == 1)
					{
						HPzombie1[k] -= 17;
						ismoveCS[i] = 0;
						keepCS[i] = 0;
						break;
					}
				}
			}
			//当普通学生遇到每一只zombiemeat：
			if (keepCS[i] == 1)
			{
				for (k = 0; k < ZombieMeatNum; k++)
				{
					if (abs(pZ_Mx[k] - pCSx[i]) < CommonStudentad&&ExistZombieMeat[k] == 1)
					{
						HPZombieMeat[k] -= 17;
						ismoveCS[i] = 0;
						keepCS[i] = 0;
						break;
					}
				}
			}
			//当普通学生遇到每一只瘦子僵尸
			if (keepCS[i] == 1)
			{
				for (k = 0; k < ZombieThinNum; k++)
				{
					if (abs(pZ_Tx[k] - pCSx[i]) < CommonStudentad&&ExistZombieThin[k] == 1)
					{
						HPZombieThin[k] -= 17;
						ismoveCS[i] = 0;
						keepCS[i] = 0;
						break;
					}
				}
			}
			//当普通学生遇到每一只boss僵尸
			if (keepCS[i] == 1)
			{
				for (k = 0; k < ZombieBossNum; k++)
				{
					if (abs(pZ_Tx[k] - pCSx[i]) < CommonStudentad&&ExistZombieBoss[k] == 1)
					{
						HPZombieBoss[k] -= 20;
						ismoveCS[i] = 0;
						keepCS[i] = 0;
						break;
					}
				}
			}
			//当普通学生遇到僵尸基地
			if (keepCS[i] == 1)
			{
				if (zombieHQ_x - pCSx[i] < CommonStudentad)
				{
					zombieHQHP -= 1;
					ismoveCS[i] = 0;
				}
			}
			//判断普通学生是否移动
			if (ismoveCS[i] == 1)
				pCSx[i] += 6;
			putimage(pCSx[i], pCSy[i] + 15, 68, 100, &CommonStudent1, CommonStudentI * 70, 0, NOTSRCERASE);
			putimage(pCSx[i], pCSy[i] + 15, 68, 100, &CommonStudent2, CommonStudentI * 70, 0, SRCINVERT);
			//循环动作
			CommonStudentI += 1;
			if (CommonStudentI == 8)
				CommonStudentI = 0;
		}
	}
}
void ToughStudentMeet()
{
	int i, k;
	//猛男学生攻击：
	for (i = 0; i < ToughStudentNum; i++)
	{
		if (ExistToughStudent[i] == 1)
		{
			if (HPToughStudent[i] <= 5)
			{
				mciSendString(_T("close toughdie"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\猛男死亡.wav alias toughdie"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play toughdie"), NULL, 0, NULL);//仅播放一次
			}
			//判断普通学生是否死亡：
			if (HPToughStudent[i] <= 1)
			{
				ExistToughStudent[i] = 0;
				pTSx[i] = 10;
				pTSy[i] = 520;
				populationshu -= 1;
			}
			ismoveTS[i] = 1;
			keepTS[i] = 1;
			//当猛男学生遇到每一只zombie1：
			if (keepTS[i] == 1)
			{
				for (k = 0; k < Zombie1Num; k++)
				{
					if (abs(pZ_1x[k] - pTSx[i]) < ToughStudentad&&ExistZombie1[k] == 1)
					{
						HPzombie1[k] -= 40;
						ismoveTS[i] = 0;
						keepTS[i] = 0;
						break;
					}
				}
			}
			//当猛男学生遇到每一只zombiemeat：
			if (keepTS[i] == 1)
			{
				for (k = 0; k < ZombieMeatNum; k++)
				{
					if (abs(pZ_Mx[k] - pTSx[i]) < ToughStudentad&&ExistZombieMeat[k] == 1)
					{
						HPZombieMeat[k] -= 40;
						ismoveTS[i] = 0;
						keepTS[i] = 0;
						break;
					}
				}
			}
			//当普通学生遇到每一只瘦子僵尸
			if (keepTS[i] == 1)
			{
				for (k = 0; k < ZombieThinNum; k++)
				{
					if (abs(pZ_Tx[k] - pTSx[i]) < ToughStudentad&&ExistZombieThin[k] == 1)
					{
						HPZombieThin[k] -= 40;
						ismoveTS[i] = 0;
						keepTS[i] = 0;
						break;
					}
				}
			}
			//当普通学生遇到每一只boss僵尸
			if (keepTS[i] == 1)
			{
				for (k = 0; k < ZombieBossNum; k++)
				{
					if (abs(pZ_Box[k] - pTSx[i]) < ToughStudentad&&ExistZombieBoss[k] == 1)
					{
						HPZombieBoss[k] -= 40;
						ismoveTS[i] = 0;
						keepTS[i] = 0;
						break;
					}
				}
			}
			//当普通学生遇到僵尸基地
			if (keepTS[i] == 1)
			{
				if (zombieHQ_x - pTSx[i] < ToughStudentad)
				{
					zombieHQHP -= 1;
					ismoveTS[i] = 0;
				}
			}
			//判断猛男学生是否移动
			if (ismoveTS[i] == 1)
			{
				pTSx[i] += 4;
				putimage(pTSx[i], pTSy[i] - 40, 144, 146, &ToughStudent2, ToughStudentI_1 * 144, 0, NOTSRCERASE);
				putimage(pTSx[i], pTSy[i] - 40, 144, 146, &ToughStudent1, ToughStudentI_1 * 144, 0, SRCINVERT);
			}
			else
			{
				putimage(pTSx[i], pTSy[i] - 50, 144, 169, &Tough_A2, ToughStudentI_2 * 144, 0, NOTSRCERASE);
				putimage(pTSx[i], pTSy[i] - 50, 144, 169, &Tough_A1, ToughStudentI_2 * 144, 0, SRCINVERT);
			}
			//循环动作_移动
			ToughStudentI_1 += 1;
			if (ToughStudentI_1 == 4)
				ToughStudentI_1 = 0;
			//循环动作_击打
			ToughStudentI_2 += 1;
			if (ToughStudentI_2 == 5)
				ToughStudentI_2 = 0;
		}
	}
}
void TTeacherMeet()
{
	int i, k, t;
	static int j = 0;
	//计科老师攻击
	for (i = 0; i < TTeacherNum; i++)
	{
		if (ExistTTeacher[i] == 1)
		{
			if (HPTTeacher[i] <= 5)
			{
				mciSendString(_T("close tdie"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\老师死亡.wav alias tdie"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play tdie"), NULL, 0, NULL);//仅播放一次
			}
			//判断计科老师是否死亡：
			if (HPTTeacher[i] <= 1)
			{
				ExistTTeacher[i] = 0;
				pTTx[i] = 10;
				pTTy[i] = 520;
				populationshu -= 1;
			}
			ismoveTT[i] = 1;
			keepTT[i] = 1;
			//召唤书系统
			j++;
			if (j == 25)
			{
				for (t = 0; t < BookNum; t++)
				{
					if (ExistBook[t] == 0)
					{
						book_x[t] = pTTx[i] + 80;
						book_y[t] = pTTy[i] + 30;
						MF_x[t] = book_x[t];
						MF_y[t] = book_y[t] - 15;
						ExistBook[t] = 1;
						ExistMagicFiled[t] = 10;
						xiu[t] = 1;
						Boom_I = 0;
						break;
					}
				}
				j = 0;
			}
			//当计科老师遇到每一只zombie1：
			if (keepTT[i] == 1)
			{
				for (k = 0; k < Zombie1Num; k++)
				{
					if (abs(pZ_1x[k] - pTTx[i]) < TTeacherad&&ExistZombie1[k] == 1)
					{
						HPzombie1[k] -= 5;
						ismoveTT[i] = 0;
						keepTT[i] = 0;
						break;
					}
				}
			}
			//当计科老师遇到每一只zombiemeat：
			if (keepTT[i] == 1)
			{
				for (k = 0; k < ZombieMeatNum; k++)
				{
					if (abs(pZ_Mx[k] - pTTx[i]) < TTeacherad&&ExistZombieMeat[k] == 1)
					{
						HPZombieMeat[k] -= 5;
						ismoveTT[i] = 0;
						keepTT[i] = 0;
						break;
					}
				}
			}
			//当计科老师遇到每一只瘦子僵尸
			if (keepTT[i] == 1)
			{
				for (k = 0; k < ZombieThinNum; k++)
				{
					if (abs(pZ_Tx[k] - pTTx[i]) < TTeacherad&&ExistZombieThin[k] == 1)
					{
						HPZombieThin[k] -= 5;
						ismoveTT[i] = 0;
						keepTT[i] = 0;
						break;
					}
				}
			}
			//当计科老师遇到每一只boss僵尸
			if (keepTT[i] == 1)
			{
				for (k = 0; k < ZombieBossNum; k++)
				{
					if (abs(pZ_Tx[k] - pTTx[i]) < TTeacherad&&ExistZombieBoss[k] == 1)
					{
						HPZombieBoss[k] -= 5;
						ismoveTT[i] = 0;
						keepTT[i] = 0;
						break;
					}
				}
			}
			//当计科老师遇到僵尸基地
			if (keepTT[i] == 1)
			{
				if (zombieHQ_x - pTTx[i] < TTeacherad)
				{
					zombieHQHP -= 1;
					ismoveTT[i] = 0;
				}
			}
			//判断计科老师是否移动
			if (ismoveTT[i] == 1)
				pTTx[i] += 4;

			putimage(pTTx[i], pTTy[i], 48, 120, &TTeacher2, TTeacherI * 48, 0, NOTSRCERASE);
			putimage(pTTx[i], pTTy[i], 48, 120, &TTeacher1, TTeacherI * 48, 0, SRCINVERT);
			//循环动作
			TTeacherI += 1;
			if (TTeacherI == 13)
				TTeacherI = 0;
		}
	}
}
void Zombie1Meet()
{
	int i, k;
	for (i = 0; i < Zombie1Num; i++)
	{
		if (ExistZombie1[i] == 1)
		{
			//判断僵尸1是否死亡
			if (HPzombie1[i] <= 1)
			{
				ExistZombie1[i] = 0;
				pZ_1x[i] = 1100;
				pZ_1y[i] = 540;
				mciSendString(_T("close LVDIE"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\小绿死亡.wav alias LVDIE"), NULL, 0, NULL);//打开小绿死亡音乐
				mciSendString(_T("play LVDIE"), NULL, 0, NULL);//仅播放一次
			}
			ismoveZ1[i] = 1;
			keepZ1[i] = 1;
			//当僵尸遇到每一个骑士
			if (keepZ1[i] == 1)
			{
				for (k = 0; k < KnightNum; k++)
				{
					if (abs(pZ_1x[i] - pKx[k]) < zombie1ad&&ExistKnight[k] == 1)
					{
						HPknight[k] -= 15;
						ismoveZ1[i] = 0;
						keepZ1[i] = 0;
						break;
					}
				}
			}
			//当僵尸遇到每一个普通学生：
			if (keepZ1[i] == 1)
			{
				for (k = 0; k < CommonStudentNum; k++)
				{
					if (abs(pZ_1x[i] - pCSx[k]) < zombie1ad&&ExistCommonStudent[k] == 1)
					{
						HPCommonStudent[k] -= 15;
						ismoveZ1[i] = 0;
						keepZ1[i] = 0;
						break;
					}
				}
			}
			//当僵尸遇到每一个猛男学生：
			if (keepZ1[i] == 1)
			{
				for (k = 0; k < ToughStudentNum; k++)
				{
					if (abs(pZ_1x[i] - pTSx[k]) < zombie1ad&&ExistToughStudent[k] == 1)
					{
						HPToughStudent[k] -= 15;
						ismoveZ1[i] = 0;
						keepZ1[i] = 0;
						break;
					}
				}
			}
			//当僵尸遇到每一个计科老师：
			if (keepZ1[i] == 1)
			{
				for (k = 0; k < TTeacherNum; k++)
				{
					if (abs(pZ_1x[i] - pTTx[k]) < zombie1ad&&ExistTTeacher[k] == 1)
					{
						HPTTeacher[k] -= 15;
						ismoveZ1[i] = 0;
						keepZ1[i] = 0;
						break;
					}
				}
			}
			//当僵尸遇到人类基地：
			if (keepZ1[i] == 1)
			{
				if (pZ_1x[i] - basement_x - 50 < zombie1ad)
				{
					basementHP -= 1;
					ismoveZ1[i] = 0;
				}
			}
			//判断僵尸1是否移动：
			if (ismoveZ1[i] == 1)
				pZ_1x[i] -= 8;
			putimage(pZ_1x[i], pZ_1y[i] - 20, 88, 130, &zombie1_2, zombie_1I * 88, 0, NOTSRCERASE);
			putimage(pZ_1x[i], pZ_1y[i] - 20, 88, 130, &zombie1_1, zombie_1I * 88, 0, SRCINVERT);
			//循环动作：
			zombie_1I -= 1;
			if (zombie_1I == -1)
				zombie_1I = 3;
		}
	}
}
void ZombieMeatMeet()
{
	int i, k;
	for (i = 0; i < ZombieMeatNum; i++)
	{
		if (ExistZombieMeat[i] == 1)
		{
			//判断僵尸1是否死亡
			if (HPZombieMeat[i] <= 1)
			{
				ExistZombieMeat[i] = 0;
				pZ_Mx[i] = 1050;
				pZ_My[i] = 540;
				mciSendString(_T("close MeatDie"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\小肉死亡.mp3 alias MeatDie"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play MeatDie"), NULL, 0, NULL);//仅播放一次
			}
			ismoveZM[i] = 1;
			keepZM[i] = 1;
			//当小肉遇到每一个骑士
			if (keepZM[i] == 1)
			{
				for (k = 0; k < KnightNum; k++)
				{
					if (abs(pZ_Mx[i] - pKx[k]) < ZombieMeatad&&ExistKnight[k] == 1)
					{
						HPknight[k] -= 8;
						ismoveZM[i] = 0;
						keepZM[i] = 0;
						break;
					}
				}
			}
			//当小肉遇到每一个普通学生：
			if (keepZM[i] == 1)
			{
				for (k = 0; k < CommonStudentNum; k++)
				{
					if (abs(pZ_Mx[i] - pCSx[k]) < ZombieMeatad&&ExistCommonStudent[k] == 1)
					{
						HPCommonStudent[k] -= 8;
						ismoveZM[i] = 0;
						keepZM[i] = 0;
						break;
					}
				}
			}
			//当小肉遇到每一个猛男学生：
			if (keepZM[i] == 1)
			{
				for (k = 0; k < ToughStudentNum; k++)
				{
					if (abs(pZ_Mx[i] - pTSx[k]) < ZombieMeatad&&ExistToughStudent[k] == 1)
					{
						HPToughStudent[k] -= 8;
						ismoveZM[i] = 0;
						keepZM[i] = 0;
						break;
					}
				}
			}
			//当小肉遇到每一个计科老师：
			if (keepZM[i] == 1)
			{
				for (k = 0; k < TTeacherNum; k++)
				{
					if (abs(pZ_Mx[i] - pTTx[k]) < ZombieMeatad&&ExistTTeacher[k] == 1)
					{
						HPTTeacher[k] -= 8;
						ismoveZM[i] = 0;
						keepZM[i] = 0;
						break;
					}
				}
			}
			//当小肉遇到人类基地：
			if (keepZM[i] == 1)
			{
				if (pZ_Mx[i] - basement_x - 50 < ZombieMeatad)
				{
					basementHP -= 1;
					ismoveZM[i] = 0;
				}
			}
			//判断小肉是否移动：
			if (ismoveZM[i] == 1)
				pZ_Mx[i] -= 4;
			putimage(pZ_Mx[i], pZ_My[i] - 50, 131, 160, &ZombieMeat_2, ZombieMeat_I * 131, 0, NOTSRCERASE);
			putimage(pZ_Mx[i], pZ_My[i] - 50, 131, 160, &ZombieMeat_1, ZombieMeat_I * 131, 0, SRCINVERT);
			//循环动作：
			ZombieMeat_I -= 1;
			if (ZombieMeat_I == -1)
				ZombieMeat_I = 5;
		}
	}
}
void ZombieThinMeet()
{
	int i, k, t;
	static int j = 0;
	static int firesound = 0;
	firesound++;
	for (i = 0; i < ZombieThinNum; i++)
	{
		if (ExistZombieThin[i] == 1)
		{
			//判断Thin是否死亡
			if (HPZombieThin[i] <= 1)
			{
				ExistZombieThin[i] = 0;
				pZ_Tx[i] = 1050;
				pZ_Ty[i] = 540;
			}
			ismoveZT[i] = 1;
			keepZT[i] = 1;

			//瘦子子弹系统
			j++;
			if (j == 30)
			{
				for (t = 0; t < BulletNum; t++)
				{
					if (ExistBullet[t] == 0)
					{

						ThinBullet_x[t] = pZ_Tx[i];
						ThinBullet_y[t] = pZ_Ty[i] + 15;
						ExistBullet[t] = 1;
						if (firesound >= 15)
						{
							mciSendString(_T("close fire"), NULL, 0, NULL);
							mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\火.wav alias fire"), NULL, 0, NULL);//打开死亡音乐
							mciSendString(_T("play fire"), NULL, 0, NULL);//仅播放一次
							firesound = 0;
						}


						break;
					}
				}
				j = 0;
			}

			//当瘦子遇到每一个骑士
			if (keepZT[i] == 1)
			{
				for (k = 0; k < KnightNum; k++)
				{
					if (abs(pZ_Tx[i] - pKx[k]) < ZombieThinad)
					{
						HPknight[k] -= 5;
						ismoveZT[i] = 0;
						break;
					}
				}
			}
			//当瘦子遇到每一个普通学生：
			if (keepZT[i] == 1)
			{
				for (k = 0; k < CommonStudentNum; k++)
				{
					if (abs(pZ_Tx[i] - pCSx[k]) < ZombieThinad&&ExistCommonStudent[k] == 1)
					{
						HPCommonStudent[k] -= 5;
						ismoveZT[i] = 0;
						keepZT[i] = 0;
						break;
					}
				}
			}
			//当瘦子遇到每一个猛男学生：
			if (keepZT[i] == 1)
			{
				for (k = 0; k < ToughStudentNum; k++)
				{
					if (abs(pZ_Tx[i] - pTSx[k]) < ZombieThinad&&ExistToughStudent[k] == 1)
					{
						HPToughStudent[k] -= 5;
						ismoveZT[i] = 0;
						keepZT[i] = 0;
						break;
					}
				}
			}
			//当瘦子遇到每一个计科老师：
			if (keepZT[i] == 1)
			{
				for (k = 0; k < TTeacherNum; k++)
				{
					if (abs(pZ_Tx[i] - pTTx[k]) < ZombieThinad&&ExistTTeacher[k] == 1)
					{
						HPTTeacher[k] -= 5;
						ismoveZT[i] = 0;
						keepZT[i] = 0;
						break;
					}
				}
			}
			//当僵尸遇到人类基地：
			if (keepZT[i] == 1)
			{
				if (pZ_Tx[i] - basement_x - 50 < ZombieThinad)
				{
					basementHP -= 1;
					ismoveZT[i] = 0;
				}
			}
			//判断瘦子是否移动：
			if (ismoveZT[i] == 1)
				pZ_Tx[i] -= 4;
			putimage(pZ_Tx[i], pZ_Ty[i], 82, 91, &ZombieThin_2, ZombieThin_I * 82, 0, NOTSRCERASE);
			putimage(pZ_Tx[i], pZ_Ty[i], 82, 91, &ZombieThin_1, ZombieThin_I * 82, 0, SRCINVERT);
			//循环动作：
			ZombieThin_I -= 1;
			if (ZombieThin_I == -1)
				ZombieThin_I = 4;
		}
	}
}
void ZombieBatMeet()
{
	static int A_F[ZombieBatNum] = { 0 };
	int i, k;
	for (i = 0; i < ZombieBatNum; i++)
	{
		if (ExistZombieBat[i] == 1)
		{
			//判断蝙蝠是否死亡
			if (HPZombieBat[i] <= 80)
			{
				mciSendString(_T("close BatDie"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\蝙蝠死亡.wav alias BatDie"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play BatDie"), NULL, 0, NULL);//仅播放一次
			}
			if (HPZombieBat[i] <= 1)
			{
				ExistZombieBat[i] = 0;
				pZ_Bx[i] = 1050;
				pZ_By[i] = 540;

			}
			ismoveZB[i] = 1;
			keepZB[i] = 1;
			//当蝙蝠遇到每一个骑士
			if (keepZB[i] == 1)
			{
				for (k = 0; k < KnightNum; k++)
				{
					if (abs(pZ_Bx[i] - pKx[k]) < ZombieMeatad&&ExistKnight[k] == 1)
					{
						A_F[i]++;
						if (A_F[i] == 5)
						{
							HPknight[k] -= (20) / 2;   //括号中输出真实伤害
							pZ_By[i] = pKy[i] - 100;
							if (Jamp[i] == -1)
								pZ_By[i] = Rand_Bat_y[i];
							Jamp[i] *= -1;
							A_F[i] = 0;
						}
						ismoveZB[i] = 0;
						keepZB[i] = 1;
						break;
					}
				}
			}
			//当蝙蝠遇到每一个普通学生：
			if (keepZB[i] == 1)
			{
				for (k = 0; k < CommonStudentNum; k++)
				{
					if (abs(pZ_Bx[i] - pCSx[k]) < ZombieBatad&&ExistCommonStudent[k] == 1)
					{
						A_F[i]++;
						if (A_F[i] == 5)
						{
							HPCommonStudent[k] -= (20) / 2;
							pZ_By[i] = pCSy[i] - 100;
							if (Jamp[i] == -1)
								pZ_By[i] = Rand_Bat_y[i];
							Jamp[i] *= -1;
							A_F[i] = 0;
						}
						ismoveZB[i] = 0;
						keepZB[i] = 0;
						break;
					}
				}
			}
			//当蝙蝠遇到每一个猛男学生：
			if (keepZB[i] == 1)
			{
				for (k = 0; k < ToughStudentNum; k++)
				{
					if (abs(pZ_Bx[i] - pTSx[k]) < ZombieBatad&&ExistToughStudent[k] == 1)
					{
						A_F[i]++;
						if (A_F[i] == 5)
						{
							HPToughStudent[k] -= (20) / 2;
							pZ_By[i] = pTSy[i] - 100;
							if (Jamp[i] == -1)
								pZ_By[i] = Rand_Bat_y[i];
							Jamp[i] *= -1;
							A_F[i] = 0;
						}
						ismoveZB[i] = 0;
						keepZB[i] = 0;
						break;
					}
				}
			}
			//当蝙蝠遇到每一个计科老师：
			if (keepZB[i] == 1)
			{
				for (k = 0; k < TTeacherNum; k++)
				{
					if (abs(pZ_Bx[i] - pTTx[k]) < ZombieBatad&&ExistTTeacher[k] == 1)
					{
						A_F[i]++;
						if (A_F[i] == 5)
						{
							HPTTeacher[k] -= (20) / 2;
							pZ_By[i] = pTTy[i] - 100;
							if (Jamp[i] == -1)
								pZ_By[i] = Rand_Bat_y[i];
							Jamp[i] *= -1;
							A_F[i] = 0;
						}
						ismoveZB[i] = 0;
						keepZB[i] = 0;
						break;
					}
				}
			}
			//当蝙蝠遇到人类基地：
			if (keepZB[i] == 1)
			{
				if (pZ_Bx[i] - basement_x - 50 < ZombieBatad)
				{
					A_F[i]++;
					if (A_F[i] == 5)
					{
						pZ_By[i] = basement_y - 100;
						if (Jamp[i] == -1)
							pZ_By[i] = Rand_Bat_y[i];
						Jamp[i] *= -1;
						A_F[i] = 0;
						basementHP -= 1;
					}

					ismoveZB[i] = 0;
				}
			}
			//判断蝙蝠是否移动：
			if (ismoveZB[i] == 1)
			{
				pZ_Bx[i] -= 4;
				if (pZ_By[i] > Rand_Bat_y[i])
					pZ_By[i] -= 8;
			}
			putimage(pZ_Bx[i], pZ_By[i], 70, 100, &ZombieBat_2, ZombieBat_I * 70, 0, NOTSRCERASE);
			putimage(pZ_Bx[i], pZ_By[i], 70, 100, &ZombieBat_1, ZombieBat_I * 70, 0, SRCINVERT);
			//循环动作：
			ZombieBat_I -= 1;
			if (ZombieBat_I == -1)
				ZombieBat_I = 5;
		}
	}
}
void ZombieBossMeet()
{
	int i, k;
	for (i = 0; i < ZombieBossNum; i++)
	{
		if (ExistZombieBoss[i] == 1)
		{
			//判断boss是否死亡
			if (HPZombieBoss[i] <= 100)
			{
				mciSendString(_T("close BossDie"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\boss死亡.wav alias BossDie"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play BossDie"), NULL, 0, NULL);//仅播放一次
			}
			if (HPZombieBoss[i] <= 1)
			{
				ExistZombieBoss[i] = 0;
				pZ_Box[i] = 1050;
				pZ_Boy[i] = 540;
			}
			ismoveZBo[i] = 1;
			keepZBo[i] = 1;
			//当boss遇到每一个骑士
			if (keepZBo[i] == 1)
			{
				for (k = 0; k < KnightNum; k++)
				{
					if (abs(pZ_Box[i] - pKx[k]) < ZombieBossad&&ExistKnight[k] == 1)
					{
						HPknight[k] -= 50;
						ismoveZBo[i] = 0;
						keepZBo[i] = 0;
						break;
					}
				}
			}
			//当boss遇到每一个普通学生：
			if (keepZBo[i] == 1)
			{
				for (k = 0; k < CommonStudentNum; k++)
				{
					if (abs(pZ_Box[i] - pCSx[k]) < ZombieBossad&&ExistCommonStudent[k] == 1)
					{
						HPCommonStudent[k] -= 50;
						ismoveZBo[i] = 0;
						keepZBo[i] = 0;
						break;
					}
				}
			}
			//当boss遇到每一个猛男学生：
			if (keepZBo[i] == 1)
			{
				for (k = 0; k < ToughStudentNum; k++)
				{
					if (abs(pZ_Box[i] - pTSx[k]) < ZombieBossad&&ExistToughStudent[k] == 1)
					{
						HPToughStudent[k] -= 50;
						ismoveZBo[i] = 0;
						keepZBo[i] = 0;
						break;
					}
				}
			}
			//当boss遇到每一个计科老师：
			if (keepZBo[i] == 1)
			{
				for (k = 0; k < TTeacherNum; k++)
				{
					if (abs(pZ_Box[i] - pTTx[k]) < ZombieBossad&&ExistTTeacher[k] == 1)
					{
						HPTTeacher[k] -= 50;
						ismoveZBo[i] = 0;
						keepZBo[i] = 0;
						break;
					}
				}
			}
			//当boss遇到人类基地：
			if (keepZBo[i] == 1)
			{
				if (pZ_Box[i] - basement_x - 50 < ZombieBossad)
				{
					basementHP -= 1;
					ismoveZBo[i] = 0;
				}
			}
			//判断boss是否移动：
			if (ismoveZBo[i] == 1)
			{
				pZ_Box[i] -= 10;
				//1467 180 6
				putimage(pZ_Box[i], pZ_Boy[i] - 130, 326, 240, &ZombieBossWalk_2, ZombieBossWalk_I * 326, 0, NOTSRCERASE);
				putimage(pZ_Box[i], pZ_Boy[i] - 130, 326, 240, &ZombieBossWalk_1, ZombieBossWalk_I * 326, 0, SRCINVERT);
			}
			//1267 280 4
			if (ismoveZBo[i] == 0)
			{
				putimage(pZ_Box[i], pZ_Boy[i] - 155, 317, 280, &ZombieBossAttack_2, ZombieBossWalk_I * 317, 0, NOTSRCERASE);
				putimage(pZ_Box[i], pZ_Boy[i] - 155, 317, 280, &ZombieBossAttack_1, ZombieBossWalk_I * 317, 0, SRCINVERT);
			}
			//循环动作：
			ZombieBossWalk_I -= 1;
			if (ZombieBossWalk_I == -1)
				ZombieBossWalk_I = 5;
			ZombieBossAttack_I -= 1;
			if (ZombieBossAttack_I == -1)
				ZombieBossAttack_I = 3;
		}
	}
}
//生成僵尸系统：
void RandZombieAppear()
{
	static int process = -20;
	static int AppearZ1 = 0;
	static int AppearZM = 0;
	static int AppearZT = 0;
	static int AppearZB = 0;
	static int AppearZBo = 0;
	int i;
	//分类循环：
	AppearZ1++;
	AppearZM++;

	//阶段0：
	if (process < 0 && process >= -20)
	{
		if (AppearZ1 == 55)
		{
			Z1_AON = 1;
			AppearZ1 = 0;
			process++;
		}
		if (AppearZM == 200)
		{
			ZM_AON = 1;
			AppearZM = 0;
		}
		if (process == -5)
		{
			ZT_AON = 1;
			process++;
		}
	}

	//阶段1：
	if (process < 15 && process >= 0)
	{
		AppearZT++;
		if (AppearZ1 == 50)
		{
			Z1_AON = 1;
			AppearZ1 = 0;
			process++;
		}
		if (AppearZM == 100)
		{
			ZM_AON = 1;
			AppearZM = 0;
		}
		if (AppearZT == 300)
		{
			ZT_AON = 1;
			AppearZT = 0;
		}
	}
	//阶段2：
	else if (process >= 15 && process < 40)
	{
		AppearZT++;
		AppearZB++;
		if (AppearZ1 == 40)
		{
			Z1_AON = 1;
			AppearZ1 = 0;
			process++;
		}

		if (AppearZM == 80)
		{
			ZM_AON = 1;
			AppearZM = 0;
		}

		if (AppearZT == 250)
		{
			ZT_AON = 1;
			AppearZT = 0;
		}

		if (AppearZB == 300)
		{
			ZB_AON = 1;
			AppearZB = 0;
		}
	}
	//阶段3：
	else if (process >= 40 && process < 60)
	{
		AppearZT++;
		AppearZB++;
		AppearZBo++;
		if (AppearZ1 == 20)
		{
			Z1_AON = 1;
			AppearZ1 = 0;
			process++;
		}

		if (AppearZM == 60)
		{
			ZM_AON = 1;
			AppearZM = 0;
		}
		else if (AppearZM >= 65)
			AppearZM = 0;

		if (AppearZT == 180)
		{
			ZT_AON = 1;
			AppearZT = 0;
		}
		else if (AppearZT >= 185)
			AppearZT = 0;

		if (AppearZB == 150)
		{
			ZB_AON = 1;
			AppearZB = 0;
		}
		if (AppearZBo == 360)
		{
			ZBo_AON = 1;
			AppearZBo = 0;
		}
	}
	//阶段4：
	else if (process >= 60 && process < 100)
	{
		AppearZT++;
		AppearZB++;
		AppearZBo++;
		if (AppearZ1 == 10)
		{
			Z1_AON = 1;
			AppearZ1 = 0;
			process++;
		}

		if (AppearZM == 40)
		{
			ZM_AON = 1;
			AppearZM = 0;
		}

		if (AppearZT == 180)
		{
			ZT_AON = 1;
			AppearZT = 0;
		}

		if (AppearZB == 75)
		{
			ZB_AON = 1;
			AppearZB = 0;
		}
		if (AppearZBo == 200)
		{
			ZBo_AON = 1;
			AppearZBo = 0;
		}
	}
	//阶段4.5：
	else if (process < 130 && process >= 100)
	{
		AppearZT++;
		AppearZB++;
		AppearZBo++;
		if (AppearZ1 == 10)
		{
			Z1_AON = 1;
			AppearZ1 = 0;
			process++;
		}

		if (AppearZM == 30)
		{
			ZM_AON = 1;
			AppearZM = 0;
		}
		else if (AppearZM >= 25)
			AppearZM = 0;
		if (AppearZT == 140)
		{
			ZT_AON = 1;
			AppearZT = 0;
		}
		else if (AppearZT >= 125)
			AppearZT = 0;
		if (AppearZB == 40)
		{
			ZB_AON = 1;
			AppearZB = 0;
		}
		if (AppearZBo == 160)
		{
			ZBo_AON = 1;
			AppearZBo = 0;
		}
	}
	//阶段5：
	else if (process >= 130)
	{
		AppearZT++;
		AppearZB++;
		AppearZBo++;
		if (process == 200)
		{
			Moneyshu += 500;
		}
		if (AppearZ1 == 5)
		{
			Z1_AON = 1;
			AppearZ1 = 0;
			process++;
		}

		if (AppearZM == 20)
		{
			ZM_AON = 1;
			AppearZM = 0;
		}
		else if (AppearZM >= 25)
			AppearZM = 0;
		if (AppearZT == 110)
		{
			ZT_AON = 1;
			AppearZT = 0;
		}
		else if (AppearZT >= 125)
			AppearZT = 0;
		if (AppearZB == 40)
		{
			ZB_AON = 1;
			AppearZB = 0;
		}
		if (AppearZBo == 120)
		{
			ZBo_AON = 1;
			AppearZBo = 0;
		}
	}


	//制造僵尸
	if (Z1_AON == 1)
	{
		for (i = 0; i <= Zombie1Num; i++)
		{
			if (ExistZombie1[i] == 0)
			{
				pZ_1x[i] = 1100;
				pZ_1y[i] = 540;
				ExistZombie1[i] = 1;
				HPzombie1[i] = 80;
				Z1_AON = 0;
				break;
			}
		}
	}
	if (ZM_AON == 1)
	{
		for (i = 0; i <= ZombieMeatNum; i++)
		{
			if (ExistZombieMeat[i] == 0)
			{
				pZ_Mx[i] = 1050;
				pZ_My[i] = 540;
				ExistZombieMeat[i] = 1;
				HPZombieMeat[i] = 300;
				ZM_AON = 0;
				break;
			}
		}
	}
	if (ZT_AON == 1)
	{
		for (i = 0; i <= ZombieThinNum; i++)
		{
			if (ExistZombieThin[i] == 0)
			{
				pZ_Tx[i] = 1050;
				pZ_Ty[i] = 540;
				ExistZombieThin[i] = 1;
				HPZombieThin[i] = 100;
				ZT_AON = 0;
				break;
			}
		}
	}
	if (ZB_AON == 1)
	{
		for (i = 0; i <= ZombieBatNum; i++)
		{
			if (ExistZombieBat[i] == 0)
			{
				pZ_Bx[i] = 1050;
				pZ_By[i] = 540;
				ExistZombieBat[i] = 1;
				HPZombieBat[i] = 130;
				Rand_Bat_y[i] = (rand() % 150 + 100);
				ZB_AON = 0;
				mciSendString(_T("close BATA"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\蝙蝠出现.wav alias BATA"), NULL, 0, NULL);//打开蝙蝠叫声音乐
				mciSendString(_T("play BATA"), NULL, 0, NULL);//仅播放一次
				break;
			}
		}
	}
	if (ZBo_AON == 1)
	{
		for (i = 0; i <= ZombieBossNum; i++)
		{
			if (ExistZombieBoss[i] == 0)
			{
				pZ_Box[i] = 1050;
				pZ_Boy[i] = 540;
				ExistZombieBoss[i] = 1;
				ZBo_AON = 0;
				mciSendString(_T("close bossa"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\boss出场.wav alias bossa"), NULL, 0, NULL);//打开boss出场音乐
				mciSendString(_T("play bossa"), NULL, 0, NULL);//仅播放一次
				HPZombieBoss[i] = 1000;
				break;
			}
		}
	}
}
//远程攻击系统：
void ThinBullet()
{
	int i, k;
	for (i = 0; i < 30; i++)
	{
		//子弹移动
		if (ExistBullet[i] == 1)
		{
			ThinBullet_x[i] -= 20;
			putimage(ThinBullet_x[i], ThinBullet_y[i], &Bullet2, NOTSRCERASE);
			putimage(ThinBullet_x[i], ThinBullet_y[i], &Bullet1, SRCINVERT);

		}
		//当子弹遇到骑士
		for (k = 0; k < KnightNum; k++)
		{
			if (ThinBullet_x[i] - pKx[k] < 120 && ExistBullet[i] == 1 && ExistKnight[k] == 1)
			{
				HPknight[k] -= 30;
				ExistBullet[i] = 0;
				ThinBullet_x[i] = 1300;
				ThinBullet_y[i] = 1000;
				break;
			}
		}
		//当子弹遇到普通学生
		for (k = 0; k < CommonStudentNum; k++)
		{
			if (ThinBullet_x[i] - pCSx[k] < 120 && ExistBullet[i] == 1 && ExistCommonStudent[k] == 1)
			{
				HPCommonStudent[k] -= 30;
				ExistBullet[i] = 0;
				ThinBullet_x[i] = 1300;
				ThinBullet_y[i] = 1000;
				break;
			}
		}
		//当子弹遇到猛男学生
		for (k = 0; k < ToughStudentNum; k++)
		{
			if (ThinBullet_x[i] - pTSx[k] < 120 && ExistBullet[i] == 1 && ExistToughStudent[k] == 1)
			{
				HPToughStudent[k] -= 30;
				ExistBullet[i] = 0;
				ThinBullet_x[i] = 1300;
				ThinBullet_y[i] = 1000;
				break;
			}
		}
		//当子弹遇到老师
		for (k = 0; k < TTeacherNum; k++)
		{
			if (ThinBullet_x[i] - pTTx[k] < 100 && ExistBullet[i] == 1 && ExistTTeacher[k] == 1)
			{
				HPTTeacher[k] -= 27;
				ExistBullet[i] = 0;
				ThinBullet_x[i] = 1300;
				ThinBullet_y[i] = 1000;
				break;
			}
		}
	}
}
void TTBook()
{
	int i, k;
	for (i = 0; i < 30; i++)
	{
		//魔法阵召唤
		if (ExistMagicFiled[i] > 0)
		{
			putimage(MF_x[i], MF_y[i], &MagicFiled2, NOTSRCERASE);
			putimage(MF_x[i], MF_y[i], &MagicFiled1, SRCINVERT);
			ExistMagicFiled[i] -= 1;
		}
		//魔法书移动
		if (ExistBook[i] == 1)
		{
			book_x[i] += 25;
			putimage(book_x[i], book_y[i], &BOOK2, NOTSRCERASE);
			putimage(book_x[i], book_y[i], &BOOK1, SRCINVERT);
			if (xiu[i] == 1)
			{
				mciSendString(_T("close xiu"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\老师扔技能特效.wav alias xiu"), NULL, 0, NULL);//打开xiu音乐
				mciSendString(_T("play xiu"), NULL, 0, NULL);//仅播放一次
				xiu[i] = 0;
			}

		}
		//当魔法书遇到Z1
		for (k = 0; k < Zombie1Num; k++)
		{
			if (pZ_1x[k] - book_x[i] < 20 && ExistBook[i] == 1 && ExistZombie1[k] == 1)
			{
				HPzombie1[k] -= 45;
				ExistBook[i] = 0;
				boom_x = book_x[i];
				boom_y = book_y[i];
				book_x[i] = -100;
				book_y[i] = 0;
				existboom[i] = 4;
				mciSendString(_T("close BOOM"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\书爆炸.wav alias BOOM"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play BOOM"), NULL, 0, NULL);//仅播放一次
				break;
			}
		}

		//当子弹遇到ZM
		for (k = 0; k < ZombieMeatNum; k++)
		{
			if (pZ_Mx[k] - book_x[i] < 20 && ExistBook[i] == 1 && ExistZombieMeat[k] == 1)
			{
				HPZombieMeat[k] -= 50;
				ExistBook[i] = 0;
				boom_x = book_x[i];
				boom_y = book_y[i];
				book_x[i] = -100;
				book_y[i] = 0;
				existboom[i] = 4;
				mciSendString(_T("close BOOM"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\书爆炸.wav alias BOOM"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play BOOM"), NULL, 0, NULL);//仅播放一次
				break;
			}
		}
		//当子弹遇到ZT
		for (k = 0; k < ZombieThinNum; k++)
		{
			if (pZ_Tx[k] - book_x[i] < 20 && ExistBook[i] == 1 && ExistZombieThin[k] == 1)
			{
				HPZombieThin[k] -= 45;
				ExistBook[i] = 0;
				boom_x = book_x[i];
				boom_y = book_y[i];
				book_x[i] = -100;
				book_y[i] = 0;
				existboom[i] = 4;
				mciSendString(_T("close BOOM"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\书爆炸.wav alias BOOM"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play BOOM"), NULL, 0, NULL);//仅播放一次
				break;
			}
		}

		//当子弹遇到ZBo
		for (k = 0; k < ZombieBossNum; k++)
		{
			if (pZ_Box[k] - book_x[i] < -20 && ExistBook[i] == 1 && ExistZombieBoss[k] == 1)
			{
				HPZombieBoss[k] -= 50;
				ExistBook[i] = 0;
				boom_x = book_x[i];
				boom_y = book_y[i];
				book_x[i] = -100;
				book_y[i] = 0;
				existboom[i] = 4;
				mciSendString(_T("close BOOM"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\书爆炸.wav alias BOOM"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play BOOM"), NULL, 0, NULL);//仅播放一次
				break;
			}
		}
		if (existboom[i] >= 0)
		{
			putimage(boom_x - 70, boom_y - 50, 192, 162, &BOOM_2, Boom_I * 192, 0, NOTSRCERASE);
			putimage(boom_x - 70, boom_y - 50, 192, 162, &BOOM_1, Boom_I * 192, 0, SRCINVERT);
			Boom_I += 1;
			existboom[i] -= 1;
		}

	}
}
//雷达射炮攻击系统：
void Radar_Cannon_Shell_Attack()
{
	int i;
	int j;
	for (i = 0; i < Shellnum; i++)
	{
		//绘制子弹和子弹移动：
		if (ExistShell[i] == 1)
		{
			putimage(shell_x[i], shell_y[i], &shell_A_2, NOTSRCERASE);
			putimage(shell_x[i], shell_y[i], &shell_A_1, SRCINVERT);
			shell_x[i] = shell_x[i] + Vshell_x[i];
			shell_y[i] = shell_y[i] + Vshell_y[i];
		}
		//子弹击中：
		for (j = 0; j < Zombie1Num; j++)
		{
			//80 20
			//88 130
			if (sqrt(((shell_x[i] + 80) - (pZ_1x[j] + 44))*((shell_x[i] + 80) - (pZ_1x[j] + 44)) + ((shell_y[i] + 20) - (pZ_1y[j] + 65))*((shell_y[i] + 20) - (pZ_1y[j] + 65))) <= 55 && ExistShell[i] == 1)
			{
				HPzombie1[j] -= 20;
				ExistShell[i] = 0;
				shell_x[i] = Gun_x;
				shell_y[i] = Gun_y;
				break;
			}
		}
		for (j = 0; j < ZombieMeatNum; j++)
		{
			//80 20
			//131 160
			if (sqrt(((shell_x[i] + 80) - (pZ_Mx[j] + 65))*((shell_x[i] + 80) - (pZ_Mx[j] + 65)) + ((shell_y[i] + 20) - (pZ_My[j] + 80))*((shell_y[i] + 80) - (pZ_My[j] + 80))) <= 55 && ExistShell[i] == 1)
			{
				HPZombieMeat[j] -= 20;
				ExistShell[i] = 0;
				shell_x[i] = Gun_x;
				shell_y[i] = Gun_y;
				break;
			}
		}
		for (j = 0; j < ZombieThinNum; j++)
		{
			//80 20
			//82 91
			if (sqrt(((shell_x[i] + 80) - (pZ_Tx[j] + 41))*((shell_x[i] + 80) - (pZ_Tx[j] + 41)) + ((shell_y[i] + 20) - (pZ_Ty[j] + 45))*((shell_y[i] + 80) - (pZ_Ty[j] + 45))) <= 55 && ExistShell[i] == 1)
			{
				HPZombieThin[j] -= 20;
				ExistShell[i] = 0;
				shell_x[i] = Gun_x;
				shell_y[i] = Gun_y;
				break;
			}
		}
		for (j = 0; j < ZombieBatNum; j++)
		{
			//80 20
			//70 100
			if (sqrt(((shell_x[i] + 80) - (pZ_Bx[j] + 35))*((shell_x[i] + 80) - (pZ_Bx[j] + 35)) + ((shell_y[i] + 20) - (pZ_By[j] + 50))*((shell_y[i] + 80) - (pZ_By[j] + 50))) <= 55 && ExistShell[i] == 1)
			{
				HPZombieThin[j] -= 20;
				ExistShell[i] = 0;
				shell_x[i] = Gun_x;
				shell_y[i] = Gun_y;
				break;
			}
		}
		for (j = 0; j < ZombieBossNum; j++)
		{
			//80 20
			//326 240
			if (sqrt(((shell_x[i] + 80) - (pZ_Box[j] + 163))*((shell_x[i] + 80) - (pZ_Box[j] + 163)) + ((shell_y[i] + 20) - (pZ_Boy[j] + 120))*((shell_y[i] + 80) - (pZ_Boy[j] + 120))) <= 55 && ExistShell[i] == 1)
			{
				HPZombieBoss[j] -= 20;
				ExistShell[i] = 0;
				shell_x[i] = Gun_x;
				shell_y[i] = Gun_y;
				break;
			}
		}

	}
}
//以下是完美的激光炮攻击系统：
void LightWeaponAttack()
{
	int l;
	for (l = 0; l < 8; l++)
	{
		if (L.exit[l] == 1)
		{

			int target_x = 0, target_y = 0;
			//寻找最靠近的僵尸
			int i, j, k, b;
			int Store_Num = 0;
			int Store_Kind = 0;
			int x = 1500;
			int x_b = 1500;

			for (i = 0; i < Zombie1Num; i++)
			{
				if (ExistZombie1[i] == 1)
				{
					if (pZ_1x[i] <= x)
					{
						Store_Num = i;
						Store_Kind = 1;
						x = pZ_1x[i];
					}
				}
			}

			for (j = 0; j < ZombieMeatNum; j++)
			{
				if (ExistZombieMeat[j] == 1)
				{
					if (pZ_Mx[j] <= x)
					{
						Store_Num = j;
						Store_Kind = 2;
						x = pZ_Mx[j];
					}
				}
			}

			for (k = 0; k < ZombieThinNum; k++)
			{
				if (ExistZombieThin[k] == 1)
				{
					if (pZ_Tx[k] <= x)
					{
						Store_Num = k;
						Store_Kind = 3;
						x = pZ_Tx[k];
					}
				}
			}

			for (k = 0; k < ZombieBossNum; k++)
			{
				if (ExistZombieBoss[k] == 1)
				{
					if (pZ_Box[k] <= x)
					{
						Store_Num = k;
						Store_Kind = 5;
						x = pZ_Box[k];
					}
				}
			}
			for (b = 0; b < ZombieBatNum; b++)
			{
				if (ExistZombieBat[b] == 1)
				{
					if (pZ_Bx[b] <= x_b)
					{
						Store_Num = b;
						Store_Kind = 4;
						x_b = pZ_Bx[b];
					}
				}
			}
			//寻找结束，开始攻击：

			//攻击小绿
			if (Store_Kind == 1)
			{
				HPzombie1[Store_Num] -= 1;
				target_x = pZ_1x[Store_Num] + 30;
				target_y = pZ_1y[Store_Num] + 10;
			}
			//攻击肉盾
			else if (Store_Kind == 2)
			{
				HPZombieMeat[Store_Num] -= 1;
				target_x = pZ_Mx[Store_Num] + 50;
				target_y = pZ_My[Store_Num] - 10;
			}
			//攻击瘦子
			else if (Store_Kind == 3)
			{
				HPZombieThin[Store_Num] -= 1;
				target_x = pZ_Tx[Store_Num];
				target_y = pZ_Ty[Store_Num];
			}
			//攻击蝙蝠
			else if (Store_Kind == 4)
			{
				HPZombieBat[Store_Num] -= 1;
				target_x = pZ_Bx[Store_Num] + 20;
				target_y = pZ_By[Store_Num] + 45;
			}
			//攻击boss
			else if (Store_Kind == 5)
			{
				HPZombieBoss[Store_Num] -= 1;
				target_x = pZ_Box[Store_Num] + 160;
				target_y = pZ_Boy[Store_Num] - 40;
			}

			//绘制激光：
			if (target_x != 0 && target_y != 0)
			{
				setlinestyle(PS_SOLID, 1);
				setcolor(WHITE);
				line(L.LightWeapon_x[l] + 75, L.LightWeapon_y[l] + 17, target_x, target_y);
			}

		}
	}
}
void LightTowerAttack()
{
	static int wait = 0;
	int l;
	for (l = 0; l < 8; l++)
	{
		if (existLT == 1)
		{
			int target_x = 0, target_y = 0;
			//寻找最靠近的僵尸
			int i, j, k;
			int Store_Num = 0;
			int Store_Kind = 0;
			int x = 1500;

			for (i = 0; i < Zombie1Num; i++)
			{
				if (ExistZombie1[i] == 1)
				{
					if (pZ_1x[i] <= x)
					{
						Store_Num = i;
						Store_Kind = 1;
						x = pZ_1x[i];
					}
				}
			}

			for (j = 0; j < ZombieMeatNum; j++)
			{
				if (ExistZombieMeat[j] == 1)
				{
					if (pZ_Mx[j] <= x)
					{
						Store_Num = j;
						Store_Kind = 2;
						x = pZ_Mx[j];
					}
				}
			}

			for (k = 0; k < ZombieThinNum; k++)
			{
				if (ExistZombieThin[k] == 1)
				{
					if (pZ_Tx[k] <= x)
					{
						Store_Num = k;
						Store_Kind = 3;
						x = pZ_Tx[k];
					}
				}
			}

			for (k = 0; k < ZombieBossNum; k++)
			{
				if (ExistZombieBoss[k] == 1)
				{
					if (pZ_Box[k] <= x)
					{
						Store_Num = k;
						Store_Kind = 4;
						x = pZ_Box[k];
					}
				}
			}
			wait += 1;
			if (wait == 80 && Store_Kind != 0)
			{
				mciSendString(_T("close XUDIAN"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\蓄电.wav alias XUDIAN"), NULL, 0, NULL);//打开蓄电音乐
				mciSendString(_T("play XUDIAN"), NULL, 0, NULL);//仅播放一次
			}
			if (wait == 150)
			{
				//寻找结束，开始攻击：
				if (Store_Kind == 1)
				{
					HPzombie1[Store_Num] -= 99;
					target_x = pZ_1x[Store_Num] + 30;
					target_y = pZ_1y[Store_Num] + 10;
				}
				else if (Store_Kind == 2)
				{
					HPZombieMeat[Store_Num] -= 99;
					target_x = pZ_Mx[Store_Num] + 50;
					target_y = pZ_My[Store_Num] - 10;
				}
				else if (Store_Kind == 3)
				{
					HPZombieThin[Store_Num] -= 99;
					target_x = pZ_Tx[Store_Num] + 10;
					target_y = pZ_Ty[Store_Num] + 10;
				}
				else if (Store_Kind == 4)
				{
					HPZombieBoss[Store_Num] -= 99;
					target_x = pZ_Box[Store_Num] + 150;
					target_y = pZ_Boy[Store_Num] - 40;
				}

				//绘制激光：
				if (target_x != 0 && target_y != 0)
				{
					setlinestyle(PS_SOLID, 8);
					setcolor(BLUE);
					line(280, 330, target_x, target_y);
				}
				wait = 0;
			}
		}
	}
}
//初始化函数
void StarFInformation()
{
	Moneyshu = 250;
	Farmshu = 1;
	silvershu = 0;
	populationFshu = 4;
	populationshu = 0;
}
void StartCharacter()
{
	loadimage(&knight1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\骑士.jpg"));
	loadimage(&knight2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\骑士遮照图.jpg"));
	loadimage(&CommonStudent1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\普通学生1.png"));
	loadimage(&CommonStudent2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\普通学生2.png"));
	loadimage(&TTeacher1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\老师111.jpg"));
	loadimage(&TTeacher2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\老师222.jpg"));
	loadimage(&zombie1_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\小绿x.jpg"));
	loadimage(&zombie1_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\小绿x遮照图.jpg"));
	loadimage(&ZombieMeat_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\小肉.jpg"));
	loadimage(&ZombieMeat_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\小肉遮照图.jpg"));
	loadimage(&ZombieThin_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\瘦子1.jpg"));
	loadimage(&ZombieThin_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\瘦子2.jpg"));
	loadimage(&Bullet1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\火球1.jpg"));
	loadimage(&Bullet2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\火球2.jpg"));
	loadimage(&BOOK1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\书.jpg"));
	loadimage(&BOOK2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\书遮照图.jpg"));
	loadimage(&MagicFiled1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\魔法阵1.jpg"));
	loadimage(&MagicFiled2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\魔法阵2.jpg"));
	loadimage(&ZombieBat_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\蝙蝠1.png"));
	loadimage(&ZombieBat_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\蝙蝠2.png"));
	loadimage(&ToughStudent1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\计科猛男行走.jpg"));
	loadimage(&ToughStudent2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\计科猛男行走遮照图.jpg"));
	loadimage(&Tough_A1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\计科猛男击打.jpg"));
	loadimage(&Tough_A2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\计科猛男击打遮照图.jpg"));
	loadimage(&ZombieBossWalk_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\BOSS.jpg"));
	loadimage(&ZombieBossWalk_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\BOSS遮照图.jpg"));
	loadimage(&ZombieBossAttack_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\BOSS攻击.jpg"));
	loadimage(&ZombieBossAttack_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\BOSS攻击遮照图.jpg"));
	loadimage(&BOOM_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\爆炸.jpg"));
	loadimage(&BOOM_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\爆炸遮照图.jpg"));

}
void StartK()
{
	int i;
	for (i = 0; i < KnightNum; i++)
	{
		pKx[i] = 10;
		pKy[i] = 520;
		ExistKnight[i] = 0;
		HPknight[i] = 10;
		ismoveK[i] = 1;
		keepK[i] = 1;
	}
	knightI = 0;
	knightad = 50;
}
void StartCS()
{
	int i;
	for (i = 0; i < CommonStudentNum; i++)
	{
		pCSx[i] = 10;
		pCSy[i] = 520;
		ExistCommonStudent[i] = 0;
		HPCommonStudent[i] = 5;
		ismoveCS[i] = 1;
		keepCS[i] = 1;
	}
	CommonStudentI = 0;
	CommonStudentad = 50;
}
void StartTS()
{
	int i;
	for (i = 0; i < ToughStudentNum; i++)
	{
		pTSx[i] = 10;
		pTSy[i] = 520;
		ExistToughStudent[i] = 0;
		HPToughStudent[i] = 5;
		ismoveTS[i] = 1;
		keepTS[i] = 1;
	}
	ToughStudentI_1 = 0;
	ToughStudentI_2 = 0;
	ToughStudentad = 70;
}
void StartTT()
{
	int i;
	for (i = 0; i < TTeacherNum; i++)
	{
		pTTx[i] = 10;
		pTTy[i] = 520;
		ExistTTeacher[i] = 0;
		HPTTeacher[i] = 5;
		ismoveTT[i] = 1;
		keepTT[i] = 1;
	}
	TTeacherI = 0;
	TTeacherad = 100;
	for (i = 0; i < 1000; i++)
	{
		ExistBook[i] = 0;
		ExistMagicFiled[i] = 0;
		xiu[i] = 0;
		existboom[i] = 0;
	}
	Boom_I = 4;
}
void StartZ1()
{
	int i;
	for (i = 0; i < Zombie1Num; i++)
	{
		pZ_1x[i] = 1100;
		pZ_1y[i] = 540;
		ExistZombie1[i] = 0;
		HPzombie1[i] = 5;
		ismoveZ1[i] = 1;
		keepZ1[i] = 1;
	}
	zombie_1I = 3;
	zombie1ad = 50;
	Z1_AON = 0;
}
void StartZM()
{
	int i;
	for (i = 0; i < ZombieMeatNum; i++)
	{
		pZ_Mx[i] = 1050;
		pZ_My[i] = 540;
		ExistZombieMeat[i] = 0;
		HPZombieMeat[i] = 10;
		ismoveZM[i] = 1;
		keepZM[i] = 1;
	}
	ZombieMeat_I = 5;
	ZombieMeatad = 50;
	ZM_AON = 0;
}
void StartZT()
{
	int i;
	for (i = 0; i < ZombieThinNum; i++)
	{
		pZ_Tx[i] = 1050;
		pZ_Ty[i] = 540;
		ExistZombieThin[i] = 0;
		HPZombieThin[i] = 10;
		ismoveZT[i] = 1;
		keepZT[i] = 1;
	}
	ZombieThin_I = 4;
	ZombieThinad = 50;
	ExistBullet[BulletNum] = { 0 };
	ZT_AON = 0;
}
void StartZB()
{
	int i;
	for (i = 0; i < ZombieBatNum; i++)
	{
		pZ_Bx[i] = 1050;
		pZ_By[i] = 540;
		ExistZombieBat[i] = 0;
		HPZombieBat[i] = 10;
		ismoveZB[i] = 1;
		keepZB[i] = 1;
		Jamp[i] = 1;
	}
	ZombieBat_I = 5;
	ZombieBatad = 50;
	ZB_AON = 0;
}
void StartZBo()
{
	int i;
	for (i = 0; i < ZombieBossNum; i++)
	{
		pZ_Box[i] = 1050;
		pZ_Boy[i] = 540;
		ExistZombieBoss[i] = 0;
		HPZombieBoss[i] = 10;
		ismoveZBo[i] = 1;
		keepZBo[i] = 1;
	}
	ZombieBossWalk_I = 5;
	ZombieBossAttack_I = 3;
	ZombieBossad = 50;
	ZBo_AON = 0;
}
void StartBK_BGM_Basement()
{
	//背景音乐
	mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\M1.mp3 alias bkmusic"), NULL, 0, NULL);
	mciSendString(_T("play bkmusic repeat"), NULL, 0, NULL);//循环播放

	//初始画布
	initgraph(width, high);
	setbkcolor(BLACK);
	cleardevice();

	//背景图片
	loadimage(&img_bk, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\diebridge.jpg"));

	//双方基地
	loadimage(&HuBasement1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\人类基地.jpg"));
	loadimage(&HuBasement2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\人类基地遮照图.jpg"));
	loadimage(&img_zombieHQ1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\僵尸基地.jpg"));
	loadimage(&img_zombieHQ2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\僵尸基地遮照图.jpg"));
	basement_x = 0;             //初始化人类基地的位置
	basement_y = high * 0.7;

	zombieHQ_x = width - 200;
	zombieHQ_y = high * 0.45;

	start_zombieHQHP = 1500;                    //初始化僵尸基地血量
	start_basementHP = 1500;                    //初始化人类总部血量

	zombieHQHP = start_zombieHQHP;
	basementHP = start_basementHP;

	zombieHQ_length = 400;                      //初始化双方基地血条长度  
	basement_length = 400;

	zombieHQ_blood_x = width;               //初始化双方基地血条位置
	basement_blood_x = 0;


}
//初始化射炮系统：
void StartConstraction_radar()
{
	//人类建筑：射炮：
	Gun_x = 88;
	Gun_y = 100;
	ExistRADAR = 0;
	Hot_Or_Not = 0;
	ExistShell[Shellnum] = { 0 };
	loadimage(&Radar_Cannon_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\雷达.jpg"));
	loadimage(&Radar_Cannon_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\雷达遮照图.jpg"));
	loadimage(&shell_A_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\子弹1.jpg"));
	loadimage(&shell_A_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\子弹1遮照图.jpg"));
}
void StartConstraction()
{
	//老师召唤阵：
	ExistCallTeacher = 0;
	loadimage(&CALL_1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\老师召唤法阵1.png"));
	loadimage(&CALL_2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\老师召唤法阵2.png"));

	//人类建筑,农场
	farm_i = 1;                          // 初始化一个农场
	loadimage(&f.Farm1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\农场.png"));
	loadimage(&f.Farm2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\农场遮照图.png"));
	for (f.num = 0; f.num < 5; f.num++)
		f.farm_x[f.num] = 0;
	for (f.num = 0; f.num < 3; f.num++)
		f.farm_y[f.num] = 388 - f.num * 42;
	for (f.num = 3; f.num < 5; f.num++)
		f.farm_y[f.num] = 350 - f.num * 42;
	f.exit[0] = 1;
	for (f.num = farm_i; f.num < 5; f.num++)
	{
		f.exit[f.num] = 0;
	}

	//人类建筑，激光炮
	lightweapon_i = 0;
	loadimage(&L.LightWeapon1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\激光炮1.jpg"));
	loadimage(&L.LightWeapon2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\激光炮2.jpg"));
	for (L.num = 0; L.num < 4; L.num++)
		L.LightWeapon_x[L.num] = 300;
	for (L.num = 4; L.num < 8; L.num++)
		L.LightWeapon_x[L.num] = 380;
	for (L.num = 0; L.num < 4; L.num++)
		L.LightWeapon_y[L.num] = 385 - L.num * 37;
	for (L.num = 4; L.num < 8; L.num++)
		L.LightWeapon_y[L.num] = 385 - (L.num - 4) * 37;
	L.exit[8] = { 0 };


	//人类建筑，银厂
	silver_i = 0;                        //初始化零个银厂
	loadimage(&s.Silver1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\银厂.png"));
	loadimage(&s.Silver2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\银厂遮照图.png"));
	for (s.num = 0; s.num < 5; s.num++)
		s.silver_x[s.num] = 110;
	for (s.num = 0; s.num < 3; s.num++)
		s.silver_y[s.num] = 385 - s.num * 45;
	for (s.num = 3; s.num < 5; s.num++)
		s.silver_y[s.num] = 360 - s.num * 45;

	for (s.num = silver_i; s.num < 5; s.num++)
	{
		s.exit[s.num] = 0;
	}
	//人类建筑，马厩
	loadimage(&st.Stable1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\马厩.png"));
	loadimage(&st.Stable2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\马厩遮照图.png"));
	st.stable_x = 225;
	st.stable_y = 180;
	st.exit = 0;
	//人类建筑，兵营：
	loadimage(&sol.Soldierland1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\兵营1.jpg"));
	loadimage(&sol.Soldierland2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\兵营2.jpg"));
	sol.Soldierland_x = 330;
	sol.soldierland_y = 146;
	sol.exit = 0;
	//人类建筑，光棱塔：
	loadimage(&LightTower1, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\光棱塔1.png"));
	loadimage(&LightTower2, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\光棱塔2.png"));

	StartConstraction_radar();

}
void StartButton()
{
	//载入按钮
	loadimage(&student_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\学生按钮.png"));
	loadimage(&teacher_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\老师按钮.png"));
	loadimage(&mengnan_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\猛男按钮.png"));
	loadimage(&lightweapon_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\激光炮按钮.jpg"));
	loadimage(&lighttower_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\光棱塔按钮.png"));
	loadimage(&farm_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\农场按钮.png"));
	loadimage(&silver_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\银厂按钮.png"));
	loadimage(&stable_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\马厩按钮.png"));
	loadimage(&soldierland_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\兵营按钮.jpg"));
	loadimage(&magic_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\召唤台按钮.png"));
	loadimage(&knight_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\骑士按钮.png"));
	loadimage(&mystic_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\童晶按钮.png"));
	loadimage(&radar_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\雷达按钮.png"));
	loadimage(&danghui_button, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\党徽.png"));

}
void Startintroduction()
{

	loadimage(&student_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\计科同学说明.png"));
	loadimage(&teacher_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\计科老师说明.png"));
	loadimage(&mengnan_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\计科猛男说明.png"));
	loadimage(&lightweapon_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\激光炮说明.png"));
	loadimage(&lighttower_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\光棱塔说明.png"));
	loadimage(&farm_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\农场说明.png"));
	loadimage(&silver_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\银厂说明.png"));
	loadimage(&stable_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\马厩说明.png"));
	loadimage(&soldierland_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\兵营说明.png"));
	loadimage(&magic_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\魔法台说明.png"));
	loadimage(&knight_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\骑士说明.png"));
	loadimage(&mystic_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\童晶老师说明.png"));
	loadimage(&radar_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\雷达射炮说明.png"));
	loadimage(&danghui_int, _T("E:\\编程作业\\建筑队大战僵尸\\素材\\党徽说明.png"));
}

void startup()  //数据初始化
{
	StarFInformation();
	StartK();
	StartCS();
	StartTS();
	StartTT();
	StartZ1();
	StartZM();
	StartZT();
	StartZB();
	StartZBo();
	StartConstraction();
	StartBK_BGM_Basement();

	StartButton();

	StartCharacter();
	Startintroduction();



	while (gameStatus == 0)
		start();  //显示开始界面
	BeginBatchDraw();
}
//音效函数区


void show()
{
	putimage(0, 0, &img_bk);
	//meet函数
	KnightMeet();
	TTeacherMeet();
	CommonStudentMeet();
	ToughStudentMeet();
	Zombie1Meet();
	ZombieMeatMeet();
	ZombieThinMeet();
	ZombieBatMeet();
	ZombieBossMeet();

	//基地和血条
	TowBasement();
	HP();

	//火球和书
	ThinBullet();
	TTBook();

	//激光炮和光棱塔攻击
	LightWeaponAttack();
	LightTowerAttack();
	Radar_Cannon_Shell_Attack();

	//建筑物
	farm();
	silver();
	stable();
	lightweapon();
	soldierland();
	LightTower();
	teachercall();//老师召唤阵
	radar_cannon();




	Button();
	Introduction();


	FirstInformationBoard();
	FlushBatchDraw();

	Sleep(100);

	FlushBatchDraw();
	Sleep(1);
}
void updateWithOutInput()
{
	RandZombieAppear();
	MoneyAdd();
	if (basementHP <= 100)
		gameStatus = 2;
	if (zombieHQHP <= 0)
		gameStatus = 4;


	if (gameStatus == 2)
	{
		end_lose();
	}
	if (gameStatus == 3)
	{
		end_tongjing();
	}
	if (gameStatus == 4)
	{
		end_win();
	}

	//dadada();

}
void updateWithInput()  // 与用户输入有关的更新
{
	int i, n;
	char input;
	MOUSEMSG m;                          //记录鼠标消息
	while (MouseHit())
	{
		m = GetMouseMsg();
		mouseplace_x = m.x, mouseplace_y = m.y;
		if (Hot_Or_Not == 1)
		{
			if (m.uMsg == WM_LBUTTONDOWN)
			{
				for (n = 0; n < Shellnum; n++)
				{
					if (ExistShell[n] == 0)
					{

						VV = 0.1;
						ExistShell[n] = 1;
						shell_x[n] = Gun_x + 12;
						shell_y[n] = Gun_y + 12;
						Vshell_x[n] = VV * (mouseplace_x - Gun_x);
						Vshell_y[n] = VV * (mouseplace_y - Gun_y);
						break;
					}
				}
			}
			//单击鼠标右键结束控制
			if (m.uMsg == WM_RBUTTONDOWN)
				Hot_Or_Not = 0;

		}
		if (Hot_Or_Not == 0)
		{
			if ((m.x > 1140 && m.x < 1200 && m.y>10 && m.y < 70) && (m.uMsg == WM_LBUTTONDOWN))      //点击童晶
			{
				gameStatus = 3;

			}
			if ((m.x > 15 && m.x < 115 && m.y>83 && m.y < 204) && (m.uMsg == WM_LBUTTONDOWN))   //点击雷达实体
			{
				mciSendString(_T("close aaa"), NULL, 0, NULL);
				mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\敲键盘.wav alias aaa"), NULL, 0, NULL);//打开死亡音乐
				mciSendString(_T("play aaa"), NULL, 0, NULL);//仅播放一次
				if (ExistRADAR == 1)
					Hot_Or_Not = 1;
			}
			if ((m.x > 700 && m.x < 760 && m.y>80 && m.y < 140) && (m.uMsg == WM_LBUTTONDOWN) && (Moneyshu >= 200))   //点击农场
			{
				for (f.num = farm_i; f.num < 5; f.num++)
				{
					f.exit[f.num] = 1;
					farm_i = f.num + 1;
					Farmshu++;
					populationFshu += 4;
					Moneyshu -= 200;
					break;
				}
			}
			if ((m.x > 770 && m.x < 830 && m.y>80 && m.y < 140) && (m.uMsg == WM_LBUTTONDOWN) && (Moneyshu >= 300))  //点击银厂
			{
				for (s.num = silver_i; s.num < 5; s.num++)
				{
					s.exit[s.num] = 1;
					silver_i = s.num + 1;
					silvershu++;
					Moneyshu -= 300;
					break;
				}
			}
			if ((m.x > 920 && m.x < 1000 && m.y>80 && m.y < 140) && (m.uMsg == WM_LBUTTONDOWN) && (Moneyshu >= 1000))   //点击雷达（雷达即射炮）
			{
				if (Moneyshu >= 0 && Farmshu == 5)
				{
					ExistRADAR = 1;
					Moneyshu -= 1000;
				}
			}
			if ((m.x > 1000 && m.x < 1060 && m.y>80 && m.y < 140) && (m.uMsg == WM_LBUTTONDOWN))   //点击马厩
			{
				if (Moneyshu >= 500)
				{
					st.exit = 1;
					Moneyshu -= 500;
				}

			}
			if ((m.x > 1070 && m.x < 1130 && m.y>80 && m.y < 140) && (m.uMsg == WM_LBUTTONDOWN))   //点击兵营
			{
				if (Moneyshu >= 800)
				{
					sol.exit = 1;
					Moneyshu -= 800;
				}
			}

			if ((m.x > 770 && m.x < 830 && m.y>10 && m.y < 70) && (m.uMsg == WM_LBUTTONDOWN))   //点击骑士
			{
				if (Moneyshu >= 80 && populationshu < populationFshu&&st.exit == 1)
				{
					for (i = 0; i <= KnightNum; i++)
					{
						if (ExistKnight[i] == 0)
						{
							ExistKnight[i] = 1;
							pKx[i] = 10;
							pKy[i] = 520;
							HPknight[i] = 240;
							Moneyshu -= 80;
							populationshu += 1;
							break;
						}
					}
				}

			}
			if ((m.x > 700 && m.x < 760 && m.y>10 && m.y < 70) && (m.uMsg == WM_LBUTTONDOWN))    //点击学生
			{
				if (Moneyshu >= 30 && populationshu < populationFshu)
				{
					for (i = 0; i <= CommonStudentNum; i++)
					{
						if (ExistCommonStudent[i] == 0)
						{
							ExistCommonStudent[i] = 1;
							pCSx[i] = 10;
							pCSy[i] = 520;
							HPCommonStudent[i] = 110;
							Moneyshu -= 30;
							populationshu += 1;
							break;
						}
					}
				}
			}
			if ((m.x > 840 && m.x < 900 && m.y>10 && m.y < 70) && (m.uMsg == WM_LBUTTONDOWN))      //点击老师
			{
				if (Moneyshu >= 100 && populationshu < populationFshu&&ExistCallTeacher == 1)
				{
					for (i = 0; i < TTeacherNum; i++)
					{
						if (ExistTTeacher[i] == 0)
						{
							ExistTTeacher[i] = 1;
							pTTx[i] = 10;
							pTTy[i] = 520;
							HPTTeacher[i] = 100;
							Moneyshu -= 100;
							populationshu += 1;
							break;
						}
					}
				}

			}
			if ((m.x > 1000 && m.x < 1060 && m.y>10 && m.y < 70) && (m.uMsg == WM_LBUTTONDOWN))      //点击激光炮
			{
				if (Moneyshu >= 200)
				{
					for (L.num = lightweapon_i; L.num < 8; L.num++)
					{
						L.exit[L.num] = 1;
						lightweapon_i = lightweapon_i + 1;
						Moneyshu -= 200;
						mciSendString(_T("close zizi"), NULL, 0, NULL);
						mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\滋滋滋.wav alias zizi"), NULL, 0, NULL);//打开死亡音乐
						mciSendString(_T("play zizi"), NULL, 0, NULL);//仅播放一次
						break;
					}
				}
			}
			if ((m.x > 1070 && m.x < 1140 && m.y>10 && m.y < 70) && (m.uMsg == WM_LBUTTONDOWN))      //点击光棱塔
			{
				if (Moneyshu >= 1200)
				{
					existLT = 1;
					Moneyshu -= 1200;
				}

			}
			if ((m.x > 1140 && m.x < 1200 && m.y>80 && m.y < 140) && (m.uMsg == WM_LBUTTONDOWN))      //点击魔法台
			{
				if (Moneyshu >= 600)
				{
					ExistCallTeacher = 1;
					Moneyshu -= 600;
				}

			}
			if ((m.x > 840 && m.x < 900 && m.y>80 && m.y < 140) && (m.uMsg == WM_LBUTTONDOWN))      //点击猛男
			{
				if (Moneyshu >= 150 && populationshu < populationFshu&&sol.exit == 1)
				{
					for (i = 0; i <= ToughStudentNum; i++)
					{
						if (ExistToughStudent[i] == 0)
						{
							pTSx[i] = 10;
							pTSy[i] = 520;
							ExistToughStudent[i] = 1;
							HPToughStudent[i] = 360;
							Moneyshu -= 150;
							populationshu++;
							break;
						}
					}
				}
			}
		}


	}
	if (_kbhit())//判断是否有输入
	{
		input = _getch();

		if (input == 's')                   //生成小绿
		{
			for (i = 0; i <= Zombie1Num; i++)
			{
				if (ExistZombie1[i] == 0)
				{
					pZ_1x[i] = 1100;
					pZ_1y[i] = 540;
					ExistZombie1[i] = 1;
					HPzombie1[i] = 80;
					break;
				}
			}
		}
		if (input == 'q')                 //生成boss
		{
			for (i = 0; i <= ZombieBossNum; i++)
			{
				if (ExistZombieBoss[i] == 0)
				{
					pZ_Box[i] = 1050;
					pZ_Boy[i] = 540;
					ExistZombieBoss[i] = 1;
					HPZombieBoss[i] = 1000;
					break;
				}
			}
		}
		if (input == 'c')                 //生成肉
		{
			for (i = 0; i <= ZombieMeatNum; i++)
			{
				if (ExistZombieMeat[i] == 0)
				{
					pZ_Mx[i] = 1050;
					pZ_My[i] = 540;
					ExistZombieMeat[i] = 1;
					HPZombieMeat[i] = 700;
					break;
				}
			}
		}
		if (input == 'r')                  //生成蝙蝠
		{
			for (i = 0; i <= ZombieBatNum; i++)
			{
				if (ExistZombieBat[i] == 0)
				{
					pZ_Bx[i] = 1050;
					pZ_By[i] = 540;
					ExistZombieBat[i] = 1;
					HPZombieBat[i] = 130;
					Rand_Bat_y[i] = (rand() % 150 + 100);
					mciSendString(_T("close BATA"), NULL, 0, NULL);
					mciSendString(_T("open E:\\编程作业\\建筑队大战僵尸\\素材\\蝙蝠出现.wav alias BATA"), NULL, 0, NULL);//打开蝙蝠叫声音乐
					mciSendString(_T("play BATA"), NULL, 0, NULL);//仅播放一次
					break;
				}
			}
		}
		if (input == 'v')                 //生成瘦子
		{
			for (i = 0; i <= ZombieThinNum; i++)
			{
				if (ExistZombieThin[i] == 0)
				{
					pZ_Tx[i] = 1050;
					pZ_Ty[i] = 540;
					ExistZombieThin[i] = 1;
					HPZombieThin[i] = 100;
					break;
				}
			}
		}


	}
}
int main()
{
	startup();

	while (1)
	{
		updateWithInput();
		show();
		updateWithOutInput();

	}

	EndBatchDraw();
	_getch();
	closegraph();
}

